From 155183a21e106a7a1616c19f3a3249044c78d27e Mon Sep 17 00:00:00 2001 From: Abhishek Kekane Date: Mon, 18 Jul 2016 11:55:22 +0530 Subject: [PATCH] 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 --- glanceclient/common/http.py | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/glanceclient/common/http.py b/glanceclient/common/http.py index 0eb42dec..39b9e9e2 100644 --- a/glanceclient/common/http.py +++ b/glanceclient/common/http.py @@ -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