API calls to Registry now maintain Request IDs
Previously, glance-api calls to glance-registry did not include the req-UUID request ID in that call. Instead a single call to glance-api used separate request IDs for api and registry, leading to some difficulty in traceback, debugging, and tracking bugs going into glance and into registry. Previous example log in glance-api: 2015-04-21 07:25:10.359 126050 DEBUG glance.registry.client.v1.client [req-f2abec73-7a8c-4c5a-bded-f5eb82d627e4 5fca8fda352e46c7a006d4bf8083ab be 00eb1978c3394438b8988cd8a755f128 - - -] Registry request GET /images/ 05454482-f448-424b-ba9d-49d44a5af9fb HTTP 200 request id req-req-2433213 e-76c2-4ce3-95b6-d0db6cc8bdd0 do_request /opt/stack/glance/glance/ registry/client/v1/client.py:131 Updated example log in glance-api: 2015-04-21 07:27:33.057 126165 DEBUG glance.registry.client.v1.client [req-1787ffe1-0537-4357-a735-18412292434d 5fca8fda352e46c7a006d4bf8083ab be 00eb1978c3394438b8988cd8a755f128 - - -] Registry request GET /images/ 05454482-f448-424b-ba9d-49d44a5af9fb HTTP 200 request id req-req-1787ffe 1-0537-4357-a735-18412292434d do_request /opt/stack/glance/glance/ registry/client/v1/client.py:131 Now, when glance-api calls glance-registry, the api request_id is passed to registry. This helps to maintain the request ID for api and registry when user makes a single call to api. Change-Id: I871c1c17aca9af291598279db1d4057e217b4256 Closes-Bug: #1336958
This commit is contained in:
parent
00d84d1a27
commit
90d8f9b9c7
|
@ -119,6 +119,7 @@ class ContextMiddleware(BaseContextMiddleware):
|
|||
'owner_is_tenant': CONF.owner_is_tenant,
|
||||
'service_catalog': service_catalog,
|
||||
'policy_enforcer': self.policy_enforcer,
|
||||
'request_id': req.headers.get('X-Openstack-Request-ID'),
|
||||
}
|
||||
|
||||
return glance.context.RequestContext(**kwargs)
|
||||
|
|
|
@ -138,6 +138,9 @@ def get_registry_client(cxt):
|
|||
'X-Service-Catalog': jsonutils.dumps(cxt.service_catalog),
|
||||
}
|
||||
kwargs['identity_headers'] = identity_headers
|
||||
|
||||
kwargs['request_id'] = cxt.request_id
|
||||
|
||||
return client.RegistryClient(_CLIENT_HOST, _CLIENT_PORT,
|
||||
_METADATA_ENCRYPTION_KEY, **kwargs)
|
||||
|
||||
|
|
|
@ -48,6 +48,8 @@ class RegistryClient(BaseClient):
|
|||
# settings when using keystone. configure_via_auth=False disables
|
||||
# this behaviour to ensure we still send requests to the Registry API
|
||||
self.identity_headers = identity_headers
|
||||
# store available passed request id for do_request call
|
||||
self._passed_request_id = kwargs.pop('request_id', None)
|
||||
BaseClient.__init__(self, host, port, configure_via_auth=False,
|
||||
**kwargs)
|
||||
|
||||
|
@ -112,6 +114,9 @@ class RegistryClient(BaseClient):
|
|||
try:
|
||||
kwargs['headers'] = kwargs.get('headers', {})
|
||||
kwargs['headers'].update(self.identity_headers or {})
|
||||
if self._passed_request_id:
|
||||
kwargs['headers']['X-Openstack-Request-ID'] = \
|
||||
self._passed_request_id
|
||||
res = super(RegistryClient, self).do_request(method,
|
||||
action,
|
||||
**kwargs)
|
||||
|
|
Loading…
Reference in New Issue