[openstack-dev] [all] cross project communication: Return request-id to caller

Kekane, Abhishek Abhishek.Kekane at nttdata.com
Fri Dec 18 06:27:59 UTC 2015

Hi Devs,

I have submitted a cross-project specs [1] for returning request-id to the caller which was approved. For implementation we have submitted patches in python-cinderclient [2] as per design in cross-project specs. However we have found one issue while implementing this design in python-glanceclient and submitted a lite-spec [3] to address this issue.

As per the comments [4] on lite-specs, glance core are suggesting new approach to use hooks and pass empty list to each of the api, so that when the hook is executed it will append the request-id to the list.

POC code for approach suggested by glance:
# change in python-glanceclient/v2/images.py to delete api

import functools

def append_request_id(req_id_lst, response, *args, **kwargs):
    req_id = response.headers.get('x-openstack-request-id')
    if req_id:

def setup_request_id_hook(req_id_lst):
    if req_id_lst is not None:
        return dict(response=functools.partial(append_request_id, req_id_lst))

def delete(self, image_id, request_ids=None):
                hook = setup_request_id_hook(request_ids)
                url = '/v2/images/%s' % image_id
                self.http_client.delete(url, hooks=hook)

# modify the do_image_delete function (glanceclient/v2/shell.py) to look as follows:

request_ids = []
gc.images.delete(args_id, request_ids=request_ids)
print request_ids

$ glance image-delete 11887d68-7faf-4821-9a42-3ec63451067c

We have tested this approach and it is working as per expectation, only thing is that we need to make changes in every method to add hook and request_id list.
>From third-party tools, user need to pass this request-ids list as mentioned in above poc in order to get the request-id back.

My point here is, should we follow this new approach in all python-clients to maintain the consistency across openstack?

Please provide your feedback for the same.

[1] http://specs.openstack.org/openstack/openstack-specs/specs/return-request-id.html
[2] https://review.openstack.org/#/c/257170/  (base patch, followed by dependent patches)
[3] https://bugs.launchpad.net/glance/+bug/1525259
[4] https://bugs.launchpad.net/glance/+bug/1525259/comments/1 and https://bugs.launchpad.net/glance/+bug/1525259/comments/5

Thank you,

Abhishek Kekane

Disclaimer: This email and any attachments are sent in strictest confidence
for the sole use of the addressee and may contain legally privileged,
confidential, and proprietary data. If you are not the intended recipient,
please advise the sender by replying promptly to this email and then delete
and destroy this email and any attachments without any further use, copying
or forwarding.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstack.org/pipermail/openstack-dev/attachments/20151218/fcef87c2/attachment.html>

More information about the OpenStack-dev mailing list