Log request-id before exceptions raised

As of now request-id is not logged if an excpetion
is raised.

Rearranged code so that request-id is logged even in case of
an exception.

Change-Id: Iee0398404ee752c0d880edf3054207c35862e71a
Closes-Bug: #1603863
This commit is contained in:
Abhishek Kekane
2016-07-18 11:55:22 +05:30
parent 13093e0194
commit 155183a21e

View File

@@ -92,6 +92,16 @@ class _BaseHTTPClient(object):
return data
def _handle_response(self, resp):
# log request-id for each api cal
request_id = resp.headers.get('x-openstack-request-id')
if request_id:
LOG.debug('%(method)s call to glance-api for '
'%(url)s used request id '
'%(response_request_id)s',
{'method': resp.request.method,
'url': resp.url,
'response_request_id': request_id})
if not resp.ok:
LOG.debug("Request returned failure status %s." % resp.status_code)
raise exc.from_response(resp, resp.content)
@@ -120,16 +130,6 @@ class _BaseHTTPClient(object):
except ValueError:
body_iter = None
# log request-id for each api call
request_id = resp.headers.get('x-openstack-request-id')
if request_id:
LOG.debug('%(method)s call to glance-api for '
'%(url)s used request id '
'%(response_request_id)s',
{'method': resp.request.method,
'url': resp.url,
'response_request_id': request_id})
return resp, body_iter