summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAbhishek Kekane <abhishek.kekane@nttdata.com>2016-05-23 14:14:11 +0000
committerAbhishek Kekane <abhishek.kekane@nttdata.com>2016-05-23 14:14:55 +0000
commit7d106c677adf247c37dbc34beae5a446765128a8 (patch)
tree8278ad7e6f34a4beb20ad26ecb107d0d0f609b78
parent9e532db8b0f0ba537edef143a6f5380a2aaa1e4b (diff)
downloadpython-glanceclient-7d106c677adf247c37dbc34beae5a446765128a8.tar.gz
Revert "Add last_request_id member to HTTPClient and SessionClient"
This reverts commit 9e532db8b0f0ba537edef143a6f5380a2aaa1e4b. If glanceclient is used in multi-threaded environment, then there is a possibility of getting invalid/wrong last request-id. To avoid this, need to use thread local storage to store last-request-id and add public method to return this request-id to caller. http://specs.openstack.org/openstack/openstack-specs/specs/return-request-id.html#alternatives Change-Id: I08d8d87fc0cc291f1b930b2c0cfc110ec8394131
-rw-r--r--glanceclient/common/http.py4
-rw-r--r--glanceclient/tests/unit/test_http.py8
2 files changed, 0 insertions, 12 deletions
diff --git a/glanceclient/common/http.py b/glanceclient/common/http.py
index 2177292..1157381 100644
--- a/glanceclient/common/http.py
+++ b/glanceclient/common/http.py
@@ -116,7 +116,6 @@ class HTTPClient(_BaseHTTPClient):
self.identity_headers = kwargs.get('identity_headers')
self.auth_token = kwargs.get('token')
self.language_header = kwargs.get('language_header')
- self.last_request_id = None
if self.identity_headers:
if self.identity_headers.get('X-Auth-Token'):
self.auth_token = self.identity_headers.get('X-Auth-Token')
@@ -265,7 +264,6 @@ class HTTPClient(_BaseHTTPClient):
{'endpoint': endpoint, 'e': e})
raise exc.CommunicationError(message=message)
- self.last_request_id = resp.headers.get('x-openstack-request-id')
resp, body_iter = self._handle_response(resp)
self.log_http_response(resp)
return resp, body_iter
@@ -305,7 +303,6 @@ class SessionClient(adapter.Adapter, _BaseHTTPClient):
def __init__(self, session, **kwargs):
kwargs.setdefault('user_agent', USER_AGENT)
kwargs.setdefault('service_type', 'image')
- self.last_request_id = None
super(SessionClient, self).__init__(session, **kwargs)
def request(self, url, method, **kwargs):
@@ -332,7 +329,6 @@ class SessionClient(adapter.Adapter, _BaseHTTPClient):
dict(url=conn_url, e=e))
raise exc.CommunicationError(message=message)
- self.last_request_id = resp.headers.get('x-openstack-request-id')
return self._handle_response(resp)
diff --git a/glanceclient/tests/unit/test_http.py b/glanceclient/tests/unit/test_http.py
index e0c1219..c18660e 100644
--- a/glanceclient/tests/unit/test_http.py
+++ b/glanceclient/tests/unit/test_http.py
@@ -200,14 +200,6 @@ class TestClient(testtools.TestCase):
resp, body = self.client.get(path, headers=headers)
self.assertEqual(text, resp.text)
- def test_request_id(self):
- path = '/v1/images/detail'
- self.mock.get(self.endpoint + path,
- headers={"x-openstack-request-id": "req-aaa"})
-
- self.client.get(path)
- self.assertEqual(self.client.last_request_id, 'req-aaa')
-
def test_headers_encoding(self):
if not hasattr(self.client, 'encode_headers'):
self.skipTest('Cannot do header encoding check on SessionClient')