Migrate to oslo request_id middleware - mv 2.46
In order to support cross project request_id tracking, we need to be on oslo.middleware for request_id. This makes that change now that oslo middleware can support compat headers. api-ref is not updated yet because x-compute-request-id was apparently never documented there, and the timing on landing this is narrow because the moment a requirements update happens we'll have this new behavior. Part of bp:oslo-middleware-request-id Change-Id: I4d9f91b01de12cd0a676fc649953f98473b6b416
This commit is contained in:
parent
0cd67d23bd
commit
99c690f57e
@ -19,7 +19,7 @@
|
||||
}
|
||||
],
|
||||
"status": "CURRENT",
|
||||
"version": "2.45",
|
||||
"version": "2.46",
|
||||
"min_version": "2.1",
|
||||
"updated": "2013-07-23T11:33:21Z"
|
||||
}
|
||||
|
@ -22,7 +22,7 @@
|
||||
}
|
||||
],
|
||||
"status": "CURRENT",
|
||||
"version": "2.45",
|
||||
"version": "2.46",
|
||||
"min_version": "2.1",
|
||||
"updated": "2013-07-23T11:33:21Z"
|
||||
}
|
||||
|
@ -15,30 +15,22 @@
|
||||
|
||||
"""Middleware that ensures x-compute-request-id
|
||||
|
||||
Using this middleware provides a convenient way to attach the
|
||||
x-compute-request-id to only v2 responses. Previously, this header was set in
|
||||
api/openstack/wsgi.py
|
||||
Nova's notion of request-id tracking predates any common idea, so the
|
||||
original version of this header in OpenStack was
|
||||
x-compute-request-id. Eventually we got oslo, and all other projects
|
||||
implemented this with x-openstack-request-id.
|
||||
|
||||
However, x-compute-request-id was always part of our contract. The
|
||||
following migrates us to use x-openstack-request-id as well, by using
|
||||
the common middleware.
|
||||
|
||||
Responses for v2.1 API are taken care of by the request_id middleware provided
|
||||
in oslo.
|
||||
"""
|
||||
|
||||
from oslo_context import context
|
||||
from oslo_middleware import base
|
||||
import webob.dec
|
||||
from oslo_middleware import request_id
|
||||
|
||||
|
||||
ENV_REQUEST_ID = 'openstack.request_id'
|
||||
HTTP_RESP_HEADER_REQUEST_ID = 'x-compute-request-id'
|
||||
|
||||
|
||||
class ComputeReqIdMiddleware(base.Middleware):
|
||||
|
||||
@webob.dec.wsgify
|
||||
def __call__(self, req):
|
||||
req_id = context.generate_request_id()
|
||||
req.environ[ENV_REQUEST_ID] = req_id
|
||||
response = req.get_response(self.application)
|
||||
if HTTP_RESP_HEADER_REQUEST_ID not in response.headers:
|
||||
response.headers.add(HTTP_RESP_HEADER_REQUEST_ID, req_id)
|
||||
return response
|
||||
class ComputeReqIdMiddleware(request_id.RequestId):
|
||||
compat_headers = [HTTP_RESP_HEADER_REQUEST_ID]
|
||||
|
@ -109,6 +109,7 @@ REST_API_VERSION_HISTORY = """REST API Version History:
|
||||
header in the response for the snapshot image, they now return a
|
||||
json dict in the response body with an image_id key and uuid
|
||||
value.
|
||||
* 2.46 - Return ``X-OpenStack-Request-ID`` header on requests.
|
||||
"""
|
||||
|
||||
# The minimum and maximum versions of the API supported
|
||||
@ -117,7 +118,7 @@ REST_API_VERSION_HISTORY = """REST API Version History:
|
||||
# Note(cyeoh): This only applies for the v2.1 API once microversions
|
||||
# support is fully merged. It does not affect the V2 API.
|
||||
_MIN_API_VERSION = "2.1"
|
||||
_MAX_API_VERSION = "2.45"
|
||||
_MAX_API_VERSION = "2.46"
|
||||
DEFAULT_API_VERSION = _MIN_API_VERSION
|
||||
|
||||
# Almost all proxy APIs which related to network, images and baremetal
|
||||
|
@ -536,3 +536,12 @@ user documentation.
|
||||
The ``createImage`` and ``createBackup`` server action APIs no longer return
|
||||
a ``Location`` header in the response for the snapshot image, they now return
|
||||
a json dict in the response body with an ``image_id`` key and uuid value.
|
||||
|
||||
2.46
|
||||
----
|
||||
|
||||
The request_id created for every inbound request is now returned in
|
||||
``X-OpenStack-Request-ID`` in addition to ``X-Compute-Request-ID``
|
||||
to be consistent with the rest of OpenStack. This is a signaling
|
||||
only microversion, as these header settings happen well before
|
||||
microversion processing.
|
||||
|
@ -23,16 +23,19 @@ from nova.api import compute_req_id
|
||||
from nova import test
|
||||
|
||||
|
||||
ENV_REQUEST_ID = 'openstack.request_id'
|
||||
|
||||
|
||||
class RequestIdTest(test.NoDBTestCase):
|
||||
def test_generate_request_id(self):
|
||||
@webob.dec.wsgify
|
||||
def application(req):
|
||||
return req.environ[compute_req_id.ENV_REQUEST_ID]
|
||||
return req.environ[ENV_REQUEST_ID]
|
||||
|
||||
app = compute_req_id.ComputeReqIdMiddleware(application)
|
||||
req = webob.Request.blank('/test')
|
||||
req_id = context.generate_request_id()
|
||||
req.environ[compute_req_id.ENV_REQUEST_ID] = req_id
|
||||
req.environ[ENV_REQUEST_ID] = req_id
|
||||
res = req.get_response(app)
|
||||
|
||||
res_id = res.headers.get(compute_req_id.HTTP_RESP_HEADER_REQUEST_ID)
|
||||
|
@ -0,0 +1,10 @@
|
||||
---
|
||||
features:
|
||||
- |
|
||||
Nova now uses oslo.middleware for request_id processing. This
|
||||
means that there is now a new ``X-OpenStack-Request-ID`` header
|
||||
returned on every request which mirrors the content of the
|
||||
existing ``X-Compute-Request-ID``. The expected existence of this
|
||||
header is signaled by Microversion 2.46. If server version >= 2.46, you
|
||||
can expect to see this header in your results (regardless of
|
||||
microversion requested).
|
@ -49,7 +49,7 @@ oslo.privsep!=1.17.0,>=1.9.0 # Apache-2.0
|
||||
oslo.i18n!=3.15.2,>=2.1.0 # Apache-2.0
|
||||
oslo.service>=1.10.0 # Apache-2.0
|
||||
rfc3986>=0.3.1 # Apache-2.0
|
||||
oslo.middleware>=3.10.0 # Apache-2.0
|
||||
oslo.middleware>=3.27.0 # Apache-2.0
|
||||
psutil>=3.2.2 # BSD
|
||||
oslo.versionedobjects>=1.17.0 # Apache-2.0
|
||||
os-brick>=1.13.0 # Apache-2.0
|
||||
|
Loading…
Reference in New Issue
Block a user