Incorrect version header return incorrect error response

Bug #1569777 reported by Jamie Hannaford
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Magnum
Fix Released
Undecided
Jaycen Grant

Bug Description

When the OpenStack-API-Version header is sent and:

- the version is outside the range of versions supported
- and is not the string "latest"

a `406 Not Acceptable` response should be returned, like so:

HTTP/1.1 406 Not Acceptable
Openstack-API-Version: magnum 5.3
Vary: OpenStack-API-Version

 {
    "errors": [
        {
            "request_id": "2ee92f06-8ede-4fb4-8921-b507601fb59d",
            "code": "magnum.microverion-unsupported",
            "status": 406,
            "title": "Requested microversion is unsupported",
            "detail": "Version 5.3 is not supported by the API. Minimum is 1.0 and maximum is 1.2.",
            "max_version": "1.2",
            "min_version": "1.0",
            "links": [
                {
                    "rel": "help",
                    "href": "http://developer.openstack.org/api-guide/compute/microversions.html"
                }
             ]
         }
     ]
}

This is in accordance with the new API-WG guideline [1].

However, Magnum currently returns a 500 Internal Server error. To test, execute the following:

$ curl -g -i -X GET http://127.0.0.1:9511/v1/baymodels -H "X-OpenStack-Magnum-API-Version: 1.0" -H "X-Auth-Token: $TOKEN"
HTTP/1.0 500 Internal Server Error
Date: Wed, 13 Apr 2016 08:53:23 GMT
Server: WSGIServer/0.1 Python/2.7.6
Content-Type: text/plain
Content-Length: 59

A server error occurred. Please contact the administrator.

[1] https://specs.openstack.org/openstack/api-wg/guidelines/microversion_specification.html

summary: - Incorrect X-OpenStack-Magnum-API-Version header returns 500 not 406
+ Incorrect version header return incorrect error response
Revision history for this message
Eli Qiao (taget-9) wrote :

@Jamie, I can not reproduce this issue:

$ curl -g -i -X GET http://10.238.157.49:9511/v1/baymodels -H "X-OpenStack-Magnum-API-Version: 1.0" -H "X-Auth-Token: $auth_token"
HTTP/1.0 406 Not Acceptable
Date: Thu, 14 Apr 2016 01:17:51 GMT
Server: WSGIServer/0.1 Python/2.7.6
X-OpenStack-Magnum-API-Minimum-Version: 1.1
X-OpenStack-Magnum-API-Maximum-Version: 1.1
Content-Type: application/json
Content-Length: 99
x-openstack-request-id: req-2ef79e0e-05d5-4cad-98ff-10b1cd122bce

{"errors": [{"status": 406, "code": "", "links": [], "title": "", "detail": "", "request_id": ""}]}

Changed in magnum:
status: New → Incomplete
Revision history for this message
Jamie Hannaford (jamie-hannaford) wrote :

I'm using devstack, do you know whether it could be wrapping errors with a generic 500 or something? This is the output from magnum-api:

Traceback (most recent call last):
  File "/usr/lib/python2.7/wsgiref/handlers.py", line 85, in run
    self.result = application(self.environ, self.start_response)
  File "/usr/local/lib/python2.7/dist-packages/webob/dec.py", line 130, in __call__
    resp = self.call_func(req, *args, **self.kwargs)
  File "/usr/local/lib/python2.7/dist-packages/webob/dec.py", line 195, in call_func
    return self.func(req, *args, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/oslo_middleware/base.py", line 114, in __call__
    response = req.get_response(self.application)
  File "/usr/local/lib/python2.7/dist-packages/webob/request.py", line 1317, in send
    application, catch_exc_info=False)
  File "/usr/local/lib/python2.7/dist-packages/webob/request.py", line 1281, in call_application
    app_iter = application(self.environ, start_response)
  File "/opt/stack/magnum/magnum/api/middleware/auth_token.py", line 60, in __call__
    return super(AuthTokenMiddleware, self).__call__(env, start_response)
  File "/usr/local/lib/python2.7/dist-packages/webob/dec.py", line 130, in __call__
    resp = self.call_func(req, *args, **self.kwargs)
  File "/usr/local/lib/python2.7/dist-packages/webob/dec.py", line 195, in call_func
    return self.func(req, *args, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/keystonemiddleware/auth_token/__init__.py", line 467, in __call__
    response = req.get_response(self._app)
  File "/usr/local/lib/python2.7/dist-packages/webob/request.py", line 1317, in send
    application, catch_exc_info=False)
  File "/usr/local/lib/python2.7/dist-packages/webob/request.py", line 1281, in call_application
    app_iter = application(self.environ, start_response)
  File "/usr/local/lib/python2.7/dist-packages/pecan/middleware/recursive.py", line 56, in __call__
    return self.application(environ, start_response)
  File "/opt/stack/magnum/magnum/api/middleware/parsable_error.py", line 64, in __call__
    err = json.loads(err_str)
  File "/usr/lib/python2.7/json/__init__.py", line 338, in loads
    return _default_decoder.decode(s)
  File "/usr/lib/python2.7/json/decoder.py", line 366, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/usr/lib/python2.7/json/decoder.py", line 384, in raw_decode
    raise ValueError("No JSON object could be decoded")
ValueError: No JSON object could be decoded
127.0.0.1 - - [14/Apr/2016 09:53:13] "GET /v1/baymodels HTTP/1.1" 500 59

Revision history for this message
Jaycen Grant (jaycen-v-grant) wrote :

I tested this and I don't see the 500 issues even on devstack. I do notice that the error response could be updated to add the details that are in the suggested response https://specs.openstack.org/openstack/api-wg/guidelines/microversion_specification.html. Would it be better to fix those as part of this bug or close this bug and fix separately?

I am working on making sure all of the microversioning is complete for magnum and this is one of the bugs that was filed around that implementation.

Changed in magnum:
assignee: nobody → Jaycen Grant (jaycen-v-grant)
Changed in magnum:
status: Incomplete → Confirmed
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to magnum (master)

Fix proposed to branch: master
Review: https://review.openstack.org/339262

Changed in magnum:
status: Confirmed → In Progress
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to magnum (master)

Reviewed: https://review.openstack.org/339262
Committed: https://git.openstack.org/cgit/openstack/magnum/commit/?id=deb10d32a9d57f4b8b2aa370a4ddfc349b41060c
Submitter: Jenkins
Branch: master

commit deb10d32a9d57f4b8b2aa370a4ddfc349b41060c
Author: Jaycen Grant <email address hidden>
Date: Thu Jul 7 07:21:10 2016 -0700

    Updates microversion root and error messages

    This change updates the microversion http errors, headers,
    and root response messages to match microversion specs
    that can be found here:
    https://specs.openstack.org/opnstack/api-wg/guidelines/
    microversion_specifications.html

    Closes-Bug: #1569777

    Change-Id: I18f52e569aeafaa98c56136d33d152fa420d9e1c

Changed in magnum:
status: In Progress → Fix Released
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix included in openstack/magnum 3.0.0

This issue was fixed in the openstack/magnum 3.0.0 release.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.