[openstack-dev] [python-cinderclient] Return request ID to caller

Malawade, Abhijeet Abhijeet.Malawade at nttdata.com
Fri Dec 12 05:54:04 UTC 2014


HI,

I want your thoughts on blueprint 'Log Request ID Mappings' for cross projects.
BP: https://blueprints.launchpad.net/nova/+spec/log-request-id-mappings
It will enable operators to get request id's mappings easily and will be useful in analysing logs effectively.

For logging 'Request ID Mappings', client needs to return 'x-openstack-request-id' to the caller.
Currently python-cinderclient do not return 'x-openstack-request-id' back to the caller.

As of now, I could think of below two solutions to return 'request-id' back from cinder-client to the caller.

1. Return tuple containing response header and response body from all cinder-client methods.
  (response header contains 'x-openstack-request-id').

Advantages:

A.      In future, if the response headers are modified then it will be available to the caller without making any changes to the python-cinderclient code.


Disadvantages:
    A. Affects all services using python-cinderclient library as the  return type of each method is changed to tuple.
     B. Need to refactor all methods exposed by the python-cinderclient library. Also requires changes in the cross projects wherever python-cinderclient calls are being made.

Ex. :-
 From Nova, you will need to call cinder-client 'get' method like below  :-
   resp_header, volume = cinderclient(context).volumes.get(volume_id)

    x-openstack-request-id = resp_header.get('x-openstack-request-id', None)

Here cinder-client will return both response header and volume. From response header, you can get 'x-openstack-request-id'.

2. The optional parameter 'return_req_id' of type list will be passed to each of the cinder-client method. If this parameter is passed then cinder-client will append ''x-openstack-request-id' received from cinder api to this list.

This is already implemented in glance-client (for V1 api only)
Blueprint : https://blueprints.launchpad.net/python-glanceclient/+spec/return-req-id
Review link : https://review.openstack.org/#/c/68524/7

Advantages:

A.      Requires changes in the cross projects only at places wherever python-cinderclient calls are being made requiring 'x-openstack-request-id'.


Dis-advantages:

A.      Need to refactor all methods exposed by the python-cinderclient library.


Ex. :-
>From Nova, you will need to pass  return_req_id parameter as a list.
    kwargs['return_req_id'] = []
    item = cinderclient(context).volumes.get(volume_id, **kwargs)

    if kwargs.get('return_req_id'):
        x-openstack-request-id = kwargs['return_req_id'].pop()

python-cinderclient will add 'x-openstack-request-id' to the 'return_req_id' list if it is provided in kwargs.

IMO, solution #2 is better than #1 for the reasons quoted above.
Takashi NATSUME has already proposed a patch for solution #2.  Please review patch https://review.openstack.org/#/c/104482/.
Would appreciate if you can think of any other better solution than #2.

Thank you.
Abhijeet

______________________________________________________________________
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/20141212/b259a53d/attachment.html>


More information about the OpenStack-dev mailing list