]> review.fuel-infra Code Review - openstack-build/cinder-build.git/commitdiff
microversion header for legacy endpoints removed
authorscottda <scott.dangelo@hp.com>
Fri, 4 Mar 2016 13:45:25 +0000 (06:45 -0700)
committerscottda <scott.dangelo@hp.com>
Mon, 7 Mar 2016 18:58:06 +0000 (11:58 -0700)
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
cinder/tests/unit/api/test_versions.py

index 8335b14b8e70b2208a7a596c76ccb8975d4347c2..dd3df2d272b0ab68afebd4e5517d620e1e03c272 100644 (file)
@@ -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())
index 1c8fd8969d272e8953737e3eeca9fc95287fde59..0f85c0e04b72fd3e5224fd34af1108976f5d76b1 100644 (file)
@@ -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'))