From bd66dd9cca32aa3a701227a545982ed4a6745114 Mon Sep 17 00:00:00 2001 From: scottda Date: Fri, 4 Mar 2016 06:45:25 -0700 Subject: [PATCH] microversion header for legacy endpoints removed With the current implementation, a microversion header will be returned even if /v1 or /v2 API endpoints are used. This is wrong, and constitutes an API change. Remove this header for legacy endpoints /v1 and /v2. Change-Id: Ided4fb35bd5cd5af512e777f9e4af275754097be Closes-Bug: #1553194 --- cinder/api/openstack/wsgi.py | 7 ++++++- cinder/tests/unit/api/test_versions.py | 4 ---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/cinder/api/openstack/wsgi.py b/cinder/api/openstack/wsgi.py index 8335b14b8e7..dd3df2d272b 100644 --- a/cinder/api/openstack/wsgi.py +++ b/cinder/api/openstack/wsgi.py @@ -1060,6 +1060,10 @@ class Resource(wsgi.Application): return self._process_stack(request, action, action_args, content_type, body, accept) + def _is_legacy_endpoint(self, request): + version_str = request.api_version_request.get_string() + return '1.0' in version_str or '2.0' in version_str + def _process_stack(self, request, action, action_args, content_type, body, accept): """Implement the processing stack.""" @@ -1168,7 +1172,8 @@ class Resource(wsgi.Application): # python 3.x response.headers[hdr] = six.text_type(val) - if not request.api_version_request.is_null(): + if (not request.api_version_request.is_null() and + not self._is_legacy_endpoint(request)): response.headers[API_VERSION_REQUEST_HEADER] = ( VOLUME_SERVICE + ' ' + request.api_version_request.get_string()) diff --git a/cinder/tests/unit/api/test_versions.py b/cinder/tests/unit/api/test_versions.py index 1c8fd8969d2..0f85c0e04b7 100644 --- a/cinder/tests/unit/api/test_versions.py +++ b/cinder/tests/unit/api/test_versions.py @@ -108,8 +108,6 @@ class VersionsControllerTestCase(test.TestCase): ids = [v['id'] for v in version_list] self.assertEqual({'v1.0'}, set(ids)) - self.check_response(response, version) - self.assertEqual('', version_list[0].get('min_version')) self.assertEqual('', version_list[0].get('version')) @@ -126,8 +124,6 @@ class VersionsControllerTestCase(test.TestCase): ids = [v['id'] for v in version_list] self.assertEqual({'v2.0'}, set(ids)) - self.check_response(response, version) - self.assertEqual('', version_list[0].get('min_version')) self.assertEqual('', version_list[0].get('version'))