summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGoutham Pacha Ravi <gouthampravi@gmail.com>2019-03-13 16:50:27 -0700
committerTom Barron <tpb@dyncloud.net>2019-03-15 19:47:48 +0000
commit5a3be01535d3902e1ee21ca070d4918adefc2018 (patch)
tree2c303858e68e2a14f3f0c5fa8a8853758aad9b7e
parent2de32564396d252ed0e618ff4e928fe197baa78f (diff)
Fix API version inferred w/ un-versioned URLs
With [1], we fixed the issue with v1 API URLs when configuring manila with a reverse proxy, like uwsgi. However, the version discovery can be made against a "unversioned" URL, i.e, the "/" endpoint. Example version discovery target when there's no reverse proxy: curl -i -X GET www.openstack-overcloud.com:8786/ Example version discovery target when manila is configured with a web proxy: curl -i -X GET www.openstack-overcloud.com/shared-file-system/ Currently, the API assumes that a v2 endpoint is requested and hence sets a default API version in the request, which results in the wrong headers communicated to the client. Fix this issue. The release note added with [1] should suffice for this fix. [1] I0363d7174f3d7ddefa8ced59b182faed665e9c36 Change-Id: I50d1024ee8485b8290c24fa850e60755b518fff3 Closes-Bug: #1818081 (Cherry-picked from commit 4b0c953f7fe7afbbbece8db7edce8efe69fb4387)
Notes
Notes (review): Code-Review+2: Tom Barron <tpb@dyncloud.net> Workflow+1: Tom Barron <tpb@dyncloud.net> Verified+2: Zuul Submitted-by: Zuul Submitted-at: Fri, 15 Mar 2019 23:44:37 +0000 Reviewed-on: https://review.openstack.org/643431 Project: openstack/manila Branch: refs/heads/stable/rocky
-rw-r--r--manila/api/openstack/wsgi.py5
-rw-r--r--manila/tests/api/openstack/test_wsgi.py2
-rw-r--r--releasenotes/notes/bug-1818081-fix-inferred-script-name-in-case-of-proxy-urls-e33466af856708b4.yaml 2
3 files changed, 6 insertions, 3 deletions
diff --git a/manila/api/openstack/wsgi.py b/manila/api/openstack/wsgi.py
index 9f9846f..c2ac051 100644
--- a/manila/api/openstack/wsgi.py
+++ b/manila/api/openstack/wsgi.py
@@ -54,6 +54,7 @@ API_VERSION_REQUEST_HEADER = 'X-OpenStack-Manila-API-Version'
54EXPERIMENTAL_API_REQUEST_HEADER = 'X-OpenStack-Manila-API-Experimental' 54EXPERIMENTAL_API_REQUEST_HEADER = 'X-OpenStack-Manila-API-Experimental'
55 55
56V1_SCRIPT_NAME = '/v1' 56V1_SCRIPT_NAME = '/v1'
57V2_SCRIPT_NAME = '/v2'
57 58
58 59
59class Request(webob.Request): 60class Request(webob.Request):
@@ -219,7 +220,9 @@ class Request(webob.Request):
219 Microversions starts with /v2, so if a client sends a /v1 URL, then 220 Microversions starts with /v2, so if a client sends a /v1 URL, then
220 ignore the headers and request 1.0 APIs. 221 ignore the headers and request 1.0 APIs.
221 """ 222 """
222 if not self.script_name: 223 if not self.script_name or not (V1_SCRIPT_NAME in self.script_name or
224 V2_SCRIPT_NAME in self.script_name):
225 # The request is on the base URL without a major version specified
223 self.api_version_request = api_version.APIVersionRequest() 226 self.api_version_request = api_version.APIVersionRequest()
224 elif V1_SCRIPT_NAME in self.script_name: 227 elif V1_SCRIPT_NAME in self.script_name:
225 self.api_version_request = api_version.APIVersionRequest('1.0') 228 self.api_version_request = api_version.APIVersionRequest('1.0')
diff --git a/manila/tests/api/openstack/test_wsgi.py b/manila/tests/api/openstack/test_wsgi.py
index c6b8f89..3332b08 100644
--- a/manila/tests/api/openstack/test_wsgi.py
+++ b/manila/tests/api/openstack/test_wsgi.py
@@ -177,7 +177,7 @@ class RequestTest(test.TestCase):
177 177
178 self.assertIsNone(request.set_api_version_request()) 178 self.assertIsNone(request.set_api_version_request())
179 179
180 if not resource: 180 if not resource or not ('/v1' in resource or '/v2' in resource):
181 self.assertEqual(api_version.APIVersionRequest(), 181 self.assertEqual(api_version.APIVersionRequest(),
182 request.api_version_request) 182 request.api_version_request)
183 elif 'v1' in resource: 183 elif 'v1' in resource:
diff --git a/releasenotes/notes/bug-1818081-fix-inferred-script-name-in-case-of-proxy-urls-e33466af856708b4.yaml b/releasenotes/notes/bug-1818081-fix-inferred-script-name-in-case-of-proxy-urls-e33466af856708b4.yaml
index 57bcb3d..5b6f352 100644
--- a/releasenotes/notes/bug-1818081-fix-inferred-script-name-in-case-of-proxy-urls-e33466af856708b4.yaml
+++ b/releasenotes/notes/bug-1818081-fix-inferred-script-name-in-case-of-proxy-urls-e33466af856708b4.yaml
@@ -3,5 +3,5 @@ fixes:
3 - | 3 - |
4 When manila API is run behind a proxy webserver, the API service was 4 When manila API is run behind a proxy webserver, the API service was
5 parsing the major API version requested incorrectly, leading to incorrect 5 parsing the major API version requested incorrectly, leading to incorrect
6 responses. This behavior has now been fixed. See `launchpad bug 1815038 6 responses. This behavior has now been fixed. See `launchpad bug 1818081
7 <https://bugs.launchpad.net/manila/+bug/1818081>`_ for more details. \ No newline at end of file 7 <https://bugs.launchpad.net/manila/+bug/1818081>`_ for more details. \ No newline at end of file