Pass Global Request ID on with session client

Closes-bug: #1886650
Change-Id: I3a08c1beb398ba9f2556b6779c925f679bdc2c49
This commit is contained in:
Erno Kuvaja 2020-07-13 22:35:15 +01:00
parent de178ac438
commit bae1d89cc7
3 changed files with 20 additions and 1 deletions

View File

@ -352,7 +352,6 @@ class SessionClient(adapter.Adapter, _BaseHTTPClient):
def __init__(self, session, **kwargs):
kwargs.setdefault('user_agent', USER_AGENT)
kwargs.setdefault('service_type', 'image')
self.global_request_id = kwargs.pop('global_request_id', None)
super(SessionClient, self).__init__(session, **kwargs)
def request(self, url, method, **kwargs):

View File

@ -267,6 +267,20 @@ class TestClient(testtools.TestCase):
self.assertEqual(b"application/openstack-images-v2.1-json-patch",
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):
"""Verify the path being used for HTTP requests reflects accurately."""
headers = {"Content-Type": "text/plain"}

View File

@ -0,0 +1,6 @@
---
fixes:
- |
* Bug 1886650_: Glance client does not correctly forward global request IDs
.. _1886650: https://code.launchpad.net/bugs/1886650