Add x-openstack-request-id to nova v3 responses

x-openstack-request-id is the common header name for request ID going
forward. Nova, cinder, and neutron return this header. Using the
request_id middleware is a convenient way to ensure this header is in
the response. We will also be using the middleware to generate the
request ID.

The ID will be generated by the middleware and is inserted into the
request environment. The current code generates the request ID in the
constructor of RequestContext; with this change, the ID is generated
beforehand and passed in to the RequestContext constructor. Not much
different here: a request ID is generated and is available for use in
the handling of the request.

On the response end, the middleware is again used, this time to
attach the x-openstack-request-id header, using the value of the
generated request ID.

For v3, we will be using the request_id middleware provided in oslo.
For v2, nova-specific middleware (compute_request_id.py) is used.
Therefore, v3 responses will have the header x-openstack-request-id,
and v2 responses will have the header x-compute-request-id (no
change). It is necessary to move the existing code out into
middleware, so that the old header is not attached to v3 responses.

UpgradeImpact: api-paste.ini is modified

DocImpact: v3 responses of the API will only include x-openstack-request-id

Implements: blueprint cross-service-request-id
Change-Id: I5e370fd3de5ee2f8a8d13553015d88910ff5ea87
This commit is contained in:
Chris Buccella
2014-01-15 06:21:27 +00:00
parent 296f2fa183
commit 49d83e356a
9 changed files with 126 additions and 32 deletions

View File

@@ -24,6 +24,7 @@ from nova import context
from nova.openstack.common.gettextutils import _
from nova.openstack.common import jsonutils
from nova.openstack.common import log as logging
from nova.openstack.common.middleware import request_id
from nova import wsgi
@@ -113,6 +114,8 @@ class NovaKeystoneContext(wsgi.Middleware):
project_name = req.headers.get('X_TENANT_NAME')
user_name = req.headers.get('X_USER_NAME')
req_id = req.environ.get(request_id.ENV_REQUEST_ID)
# Get the auth token
auth_token = req.headers.get('X_AUTH_TOKEN',
req.headers.get('X_STORAGE_TOKEN'))
@@ -138,7 +141,8 @@ class NovaKeystoneContext(wsgi.Middleware):
roles=roles,
auth_token=auth_token,
remote_address=remote_address,
service_catalog=service_catalog)
service_catalog=service_catalog,
request_id=req_id)
req.environ['nova.context'] = ctx
return self.application