os-volume_attachments return 500 error code instead of 404 if invalid volume is specified

Bug #1431652 reported by Christine Wang
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
python-cinderclient
Invalid
Low
Christine Wang

Bug Description

If I do a DELETE of os-volume_attachments with invalid volume, 500 error code is being returned instead of 404.

The problem is at volume = self.volume_api.get(context, volume_id) where NotFound exception is not being handled. This problem is fixed in v3 API.

2015-03-12 08:49:19.146 20273 INFO nova.osapi_compute.wsgi.server [req-001f6e6e-4726-4738-a3e7-74c5c7eaaac5 None] 9.114.193.249,127.0.0.1 "DELETE /v2/dd069270f6634cafaf66777c4a2ee137/servers/e44ee780-0b57-4bcb-89ef-ab99e4d7d1a0/os-volume_attachments/volume-815308985 HTTP/1.1" status: 500 len: 295 time: 0.6408780
...
2015-03-12 08:49:18.969 20273 ERROR nova.api.openstack [req-001f6e6e-4726-4738-a3e7-74c5c7eaaac5 None] Caught error: Not Found (HTTP 404) (Request-ID: req-8d133de9-430e-41ad-819a-3f9685deed29)
2015-03-12 08:49:18.969 20273 TRACE nova.api.openstack Traceback (most recent call last):
2015-03-12 08:49:18.969 20273 TRACE nova.api.openstack File "/usr/lib/python2.7/site-packages/nova/api/openstack/__init__.py", line 125, in __call__
2015-03-12 08:49:18.969 20273 TRACE nova.api.openstack return req.get_response(self.application)
2015-03-12 08:49:18.969 20273 TRACE nova.api.openstack File "/usr/lib/python2.7/site-packages/webob/request.py", line 1296, in send
2015-03-12 08:49:18.969 20273 TRACE nova.api.openstack application, catch_exc_info=False)
2015-03-12 08:49:18.969 20273 TRACE nova.api.openstack File "/usr/lib/python2.7/site-packages/webob/request.py", line 1260, in call_application
2015-03-12 08:49:18.969 20273 TRACE nova.api.openstack app_iter = application(self.environ, start_response)
2015-03-12 08:49:18.969 20273 TRACE nova.api.openstack File "/usr/lib/python2.7/site-packages/webob/dec.py", line 144, in __call__
2015-03-12 08:49:18.969 20273 TRACE nova.api.openstack return resp(environ, start_response)
2015-03-12 08:49:18.969 20273 TRACE nova.api.openstack File "/usr/lib/python2.7/site-packages/keystonemiddleware/auth_token.py", line 748, in __call__
2015-03-12 08:49:18.969 20273 TRACE nova.api.openstack return self._call_app(env, start_response)
2015-03-12 08:49:18.969 20273 TRACE nova.api.openstack File "/usr/lib/python2.7/site-packages/keystonemiddleware/auth_token.py", line 684, in _call_app
2015-03-12 08:49:18.969 20273 TRACE nova.api.openstack return self._app(env, _fake_start_response)
2015-03-12 08:49:18.969 20273 TRACE nova.api.openstack File "/usr/lib/python2.7/site-packages/webob/dec.py", line 144, in __call__
...
2015-03-12 08:49:18.969 20273 TRACE nova.api.openstack File "/usr/lib/python2.7/site-packages/nova/api/openstack/compute/contrib/volumes.py", line 398, in delete
2015-03-12 08:49:18.969 20273 TRACE nova.api.openstack volume = self.volume_api.get(context, volume_id)
...
2015-03-12 08:49:18.969 20273 TRACE nova.api.openstack item = cinder.cinderclient(context).volumes.get(volume_id)
2015-03-12 08:49:18.969 20273 TRACE nova.api.openstack File "/usr/lib/python2.7/site-packages/cinderclient/v2/volumes.py", line 227, in get
2015-03-12 08:49:18.969 20273 TRACE nova.api.openstack return self._get("/volumes/%s" % volume_id, "volume")
2015-03-12 08:49:18.969 20273 TRACE nova.api.openstack File "/usr/lib/python2.7/site-packages/cinderclient/base.py", line 149, in _get
2015-03-12 08:49:18.969 20273 TRACE nova.api.openstack resp, body = self.api.client.get(url)
2015-03-12 08:49:18.969 20273 TRACE nova.api.openstack File "/usr/lib/python2.7/site-packages/cinderclient/client.py", line 88, in get
2015-03-12 08:49:18.969 20273 TRACE nova.api.openstack return self._cs_request(url, 'GET', **kwargs)
2015-03-12 08:49:18.969 20273 TRACE nova.api.openstack File "/usr/lib/python2.7/site-packages/cinderclient/client.py", line 85, in _cs_request
2015-03-12 08:49:18.969 20273 TRACE nova.api.openstack return self.request(url, method, **kwargs)
2015-03-12 08:49:18.969 20273 TRACE nova.api.openstack File "/usr/lib/python2.7/site-packages/cinderclient/client.py", line 80, in request
2015-03-12 08:49:18.969 20273 TRACE nova.api.openstack return super(SessionClient, self).request(*args, **kwargs)
2015-03-12 08:49:18.969 20273 TRACE nova.api.openstack File "/usr/lib/python2.7/site-packages/keystoneclient/adapter.py", line 166, in request
2015-03-12 08:49:18.969 20273 TRACE nova.api.openstack resp = super(LegacyJsonAdapter, self).request(*args, **kwargs)
2015-03-12 08:49:18.969 20273 TRACE nova.api.openstack File "/usr/lib/python2.7/site-packages/keystoneclient/adapter.py", line 89, in request
2015-03-12 08:49:18.969 20273 TRACE nova.api.openstack return self.session.request(url, method, **kwargs)
2015-03-12 08:49:18.969 20273 TRACE nova.api.openstack File "/usr/lib/python2.7/site-packages/keystoneclient/utils.py", line 318, in inner
2015-03-12 08:49:18.969 20273 TRACE nova.api.openstack return func(*args, **kwargs)
2015-03-12 08:49:18.969 20273 TRACE nova.api.openstack File "/usr/lib/python2.7/site-packages/keystoneclient/session.py", line 363, in request
2015-03-12 08:49:18.969 20273 TRACE nova.api.openstack raise exceptions.from_response(resp, method, url)
2015-03-12 08:49:18.969 20273 TRACE nova.api.openstack NotFound: Not Found (HTTP 404) (Request-ID: req-8d133de9-430e-41ad-819a-3f9685deed29)
2015-03-12 08:49:18.969 20273 TRACE nova.api.openstack
2015-03-12 08:49:19.145 20273 INFO nova.api.openstack [req-001f6e6e-4726-4738-a3e7-74c5c7eaaac5 None] http://localhost:8774/v2/dd069270f6634cafaf66777c4a2ee137/servers/e44ee780-0b57-4bcb-89ef-ab99e4d7d1a0/os-volume_attachments/volume-815308985 returned with HTTP 500

Tags: api volumes
Christine Wang (ijuwang)
Changed in nova:
assignee: nobody → Christine Wang (ijuwang)
Changed in nova:
status: New → Confirmed
importance: Undecided → Low
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to nova (master)

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

Changed in nova:
status: Confirmed → In Progress
Matt Riedemann (mriedem)
tags: added: api volumes
Revision history for this message
Alex Xu (xuhj) wrote :

The wsgi layer will tranlsate the NotFound exception to 404. And I tested this delete method, I get 404 from the v2 API.

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Change abandoned on nova (master)

Change abandoned by Christine Wang (<email address hidden>) on branch: master
Review: https://review.openstack.org/165244

Christine Wang (ijuwang)
Changed in nova:
status: In Progress → Invalid
affects: nova → python-cinderclient
Changed in python-cinderclient:
status: Invalid → Confirmed
Revision history for this message
Matthew Edmonds (edmondsw) wrote :

The problem appears to be that cinderclient uses keystoneclient (see cinderclient.client.SessionClient.request), but does not translate keystoneclient exceptions to cinderclient exceptions. Callers of cinderclient should not be expected to listen for keystoneclient exceptions here, when the error is coming back from cinder, not keystone.

Revision history for this message
Sean McGinnis (sean-mcginnis) wrote :

Keystoneclient exceptions appear to be properly converted to cinderclient exceptions now:

https://github.com/openstack/python-cinderclient/blob/master/cinderclient/client.py#L86

Addressed in change I1160a2c998919b669c39a4b739e83f5bd9d8d235.

Changed in python-cinderclient:
status: Confirmed → Invalid
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.