Pass Global Request ID on with session client
Closes-bug: #1886650 Change-Id: I3a08c1beb398ba9f2556b6779c925f679bdc2c49
This commit is contained in:
parent
de178ac438
commit
bae1d89cc7
glanceclient
releasenotes/notes
@ -352,7 +352,6 @@ class SessionClient(adapter.Adapter, _BaseHTTPClient):
|
|||||||
def __init__(self, session, **kwargs):
|
def __init__(self, session, **kwargs):
|
||||||
kwargs.setdefault('user_agent', USER_AGENT)
|
kwargs.setdefault('user_agent', USER_AGENT)
|
||||||
kwargs.setdefault('service_type', 'image')
|
kwargs.setdefault('service_type', 'image')
|
||||||
self.global_request_id = kwargs.pop('global_request_id', None)
|
|
||||||
super(SessionClient, self).__init__(session, **kwargs)
|
super(SessionClient, self).__init__(session, **kwargs)
|
||||||
|
|
||||||
def request(self, url, method, **kwargs):
|
def request(self, url, method, **kwargs):
|
||||||
|
@ -267,6 +267,20 @@ class TestClient(testtools.TestCase):
|
|||||||
self.assertEqual(b"application/openstack-images-v2.1-json-patch",
|
self.assertEqual(b"application/openstack-images-v2.1-json-patch",
|
||||||
ksarqh[b"Content-Type"])
|
ksarqh[b"Content-Type"])
|
||||||
|
|
||||||
|
def test_request_id_header_session_client(self):
|
||||||
|
global_id = "req-%s" % uuid.uuid4()
|
||||||
|
kwargs = {'global_request_id': global_id}
|
||||||
|
auth = token_endpoint.Token(self.endpoint, self.token)
|
||||||
|
sess = session.Session(auth=auth)
|
||||||
|
http_client = http.SessionClient(sess, **kwargs)
|
||||||
|
|
||||||
|
path = '/v2/images/my-image'
|
||||||
|
self.mock.get(self.endpoint + path)
|
||||||
|
http_client.get(path)
|
||||||
|
|
||||||
|
headers = self.mock.last_request.headers
|
||||||
|
self.assertEqual(global_id, headers['X-OpenStack-Request-ID'])
|
||||||
|
|
||||||
def test_raw_request(self):
|
def test_raw_request(self):
|
||||||
"""Verify the path being used for HTTP requests reflects accurately."""
|
"""Verify the path being used for HTTP requests reflects accurately."""
|
||||||
headers = {"Content-Type": "text/plain"}
|
headers = {"Content-Type": "text/plain"}
|
||||||
|
@ -0,0 +1,6 @@
|
|||||||
|
---
|
||||||
|
fixes:
|
||||||
|
- |
|
||||||
|
* Bug 1886650_: Glance client does not correctly forward global request IDs
|
||||||
|
|
||||||
|
.. _1886650: https://code.launchpad.net/bugs/1886650
|
Loading…
x
Reference in New Issue
Block a user