flavor list doesn't handle MarkerNotFound

Bug #1238519 reported by Phil Day
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
OpenStack Compute (nova)
Fix Released
Medium
Davanum Srinivas (DIMS)

Bug Description

The flavor API supports the "?marker=ID" option to return the flavor list starting from a specific point. ID in this case has to be the DB id value, not the "flavorid" which is an arbitrary string (a uuid be default).

The api/compute/flavors.py does not catch the MarkerNotFound exception raised by the DB layer when the specified flavor does not exist, resulting in a 404 error and an error in the API logs:

Note that the DB ID of flavors is not returned as part of the flavor API, so its hard to see how anyone can really make use of this feature as it stands. In addition to handling the exception (to avoid an error being logged, and give a better error message to the user) perhaps the DB query should match on ">=" rather than "==", given that the user can never knwo what IDs are valid.

Revision history for this message
Phil Day (philip-day) wrote :
Download full text (6.6 KiB)

API Log Showing Stack Trace:

2013-10-09 12:22:10.426 34648 DEBUG nova.api.openstack.wsgi [req-062b4763-5651-485c-ab87-48ccc55d0fd6 10171523426685 10329695373991] Calling method <bound method Controller.detail of <nova.api.openstack.compute.flavors.Controller object at 0x4d21f50>> _process_stack /usr/lib/python2.7/dist-packages/nova/api/openstack/wsgi.py:936
2013-10-09 12:22:10.435 34648 ERROR nova.exception [req-062b4763-5651-485c-ab87-48ccc55d0fd6 10171523426685 10329695373991] Exception in string format operation
2013-10-09 12:22:10.435 34648 TRACE nova.exception Traceback (most recent call last):
2013-10-09 12:22:10.435 34648 TRACE nova.exception File "/usr/lib/python2.7/dist-packages/nova/exception.py", line 119, in _init_
2013-10-09 12:22:10.435 34648 TRACE nova.exception message = self.msg_fmt % kwargs
2013-10-09 12:22:10.435 34648 TRACE nova.exception File "/usr/lib/python2.7/dist-packages/nova/openstack/common/gettextutils.py", line 226, in _mod_
2013-10-09 12:22:10.435 34648 TRACE nova.exception self.data % other
2013-10-09 12:22:10.435 34648 TRACE nova.exception KeyError: u'marker'
2013-10-09 12:22:10.435 34648 TRACE nova.exception
2013-10-09 12:22:10.436 34648 ERROR nova.exception [req-062b4763-5651-485c-ab87-48ccc55d0fd6 10171523426685 10329695373991] code: 404
2013-10-09 12:22:10.436 34648 ERROR nova.api.openstack [req-062b4763-5651-485c-ab87-48ccc55d0fd6 10171523426685 10329695373991] Caught error: Marker %(marker)s could not be found.
2013-10-09 12:22:10.436 34648 TRACE nova.api.openstack Traceback (most recent call last):
2013-10-09 12:22:10.436 34648 TRACE nova.api.openstack File "/usr/lib/python2.7/dist-packages/nova/api/openstack/_init.py", line 119, in __call_
2013-10-09 12:22:10.436 34648 TRACE nova.api.openstack return req.get_response(self.application)
2013-10-09 12:22:10.436 34648 TRACE nova.api.openstack File "/usr/lib/python2.7/dist-packages/webob/request.py", line 1296, in send
2013-10-09 12:22:10.436 34648 TRACE nova.api.openstack application, catch_exc_info=False)
2013-10-09 12:22:10.436 34648 TRACE nova.api.openstack File "/usr/lib/python2.7/dist-packages/webob/request.py", line 1260, in call_application
2013-10-09 12:22:10.436 34648 TRACE nova.api.openstack app_iter = application(self.environ, start_response)
2013-10-09 12:22:10.436 34648 TRACE nova.api.openstack File "/usr/lib/python2.7/dist-packages/webob/dec.py", line 144, in _call_
2013-10-09 12:22:10.436 34648 TRACE nova.api.openstack return resp(environ, start_response)
2013-10-09 12:22:10.436 34648 TRACE nova.api.openstack File "/usr/lib/python2.7/dist-packages/hp/middleware/cs_auth_token.py", line 160, in _call_
2013-10-09 12:22:10.436 34648 TRACE nova.api.openstack return super(CsAuthProtocol, self)._call_(env, start_response)
2013-10-09 12:22:10.436 34648 TRACE nova.api.openstack File "/usr/lib/python2.7/dist-packages/keystoneclient/middleware/auth_token.py", line 543, in _call_
2013-10-09 12:22:10.436 34648 TRACE nova.api.openstack return self.app(env, start_response)
2013-10-09 12:22:10.436 34648 TRACE nova.api.openstack File "/usr/lib/python2.7/dist-packages/webob/dec.py", line 144, in _call_
2013-10-09 12:22:10.436 34648 TRACE nova.api.openstack r...

Read more...

Revision history for this message
Phil Day (philip-day) wrote :

To Reproduce:

curl -k -i https://compute.systestb.hpcloud.net/v2/34837751408416/flavors/detail?marker=9999999 -X GET -H "X-Auth-Project-Id: Demo" -H "User-Agent: python-novaclient" -H "Accept: application/json" -H "X-Auth-Token: XXXXXXXXX"

HTTP/1.1 404 Not Found
nnCoection: close
Content-Length: 78
Content-Type: application/json; charset=UTF-8
Date: Fri, 11 Oct 2013 07:58:17 GMT
X-Compute-Request-Id: req-9d9ca8c0-b50b-49e1-935b-3a442fb28a4b

{"itemNotFound": {"message": "The resource could not be found.", "code": 404}}

Revision history for this message
Davanum Srinivas (DIMS) (dims-v) wrote :

Phil, i've added a review for just the exception handling here - https://review.openstack.org/51194.

Changed in nova:
status: New → In Progress
assignee: nobody → Davanum Srinivas (DIMS) (dims-v)
Changed in nova:
importance: Undecided → Medium
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to nova (master)

Reviewed: https://review.openstack.org/51194
Committed: http://github.com/openstack/nova/commit/73e337b17d7909a8cd538cb7562de870eab2ee8e
Submitter: Jenkins
Branch: master

commit 73e337b17d7909a8cd538cb7562de870eab2ee8e
Author: Davanum Srinivas <email address hidden>
Date: Fri Oct 11 07:52:57 2013 -0400

    Handle MarkerNotFound better in Flavor API

    When the specified marker is not found, we should catch the
    MarkerNotFound exception and respond with a HTTP 400 Bad
    Request with sufficient information back to the user. This
    will avoid spilling unwanted tracebacks in the logs as well.

    Change-Id: I90a658384f8814096271a193a0f3abd028062b5d
    Partial-Bug: 1238519

Changed in nova:
status: In Progress → Fix Committed
Changed in nova:
milestone: none → icehouse-1
Thierry Carrez (ttx)
Changed in nova:
status: Fix Committed → Fix Released
Thierry Carrez (ttx)
Changed in nova:
milestone: icehouse-1 → 2014.1
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.