attachment update API returns 500 when it should return 400

Bug #1907295 reported by Eric Harney
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Cinder
In Progress
Medium
Eric Harney

Bug Description

This code:

https://opendev.org/openstack/cinder/src/commit/95d00bd7a6658e2cd3066e5ae77d3a9a63bc0c8f/cinder/api/v3/attachments.py#L189

causes this code:
"Prevent double-attachment race in attachment_reserve"
https://review.opendev.org/c/openstack/cinder/+/671370
https://opendev.org/openstack/cinder/src/commit/95d00bd7a6658e2cd3066e5ae77d3a9a63bc0c8f/cinder/volume/api.py#L2254

to return an HTTP 500 for the "duplicate connectors detected on volume" case. This should return an HTTP 400 instead.

Eric Harney (eharney)
Changed in cinder:
assignee: nobody → Eric Harney (eharney)
Revision history for this message
Eric Harney (eharney) wrote :

Looking closer at this, I'm not sure why, since the attachments API code should be catching InvalidVolume. Maybe reraising InvalidVolume doesn't result in the right error code being returned via the API?

Revision history for this message
Eric Harney (eharney) wrote :

2020-12-02 14:02:09.408 28 ERROR cinder.api.v3.attachments [req-8be05ad0-c25f-4efd-bfca-ba23f17e10fb a6589c24b4724a8ca3a1206139b7b3a2 c40b5deebda84c2e9dfe6c2bf084318c - default default] Unable to update attachment.(Invalid volume: duplicate connectors detected on volume c6697aa5-1e39-41e6-ae76-8e4906517f0a).: InvalidVolume: Invalid volume: duplicate connectors detected on volume c6697aa5-1e39-41e6-ae76-8e4906517f0a
2020-12-02 14:02:09.408 28 ERROR cinder.api.v3.attachments Traceback (most recent call last):
2020-12-02 14:02:09.408 28 ERROR cinder.api.v3.attachments File "/usr/lib/python2.7/site-packages/cinder/api/v3/attachments.py", line 228, in update
2020-12-02 14:02:09.408 28 ERROR cinder.api.v3.attachments connector))
2020-12-02 14:02:09.408 28 ERROR cinder.api.v3.attachments File "<string>", line 2, in attachment_update
2020-12-02 14:02:09.408 28 ERROR cinder.api.v3.attachments File "/usr/lib/python2.7/site-packages/cinder/coordination.py", line 151, in _synchronized
2020-12-02 14:02:09.408 28 ERROR cinder.api.v3.attachments return f(*a, **k)
2020-12-02 14:02:09.408 28 ERROR cinder.api.v3.attachments File "/usr/lib/python2.7/site-packages/cinder/volume/api.py", line 2197, in attachment_update
2020-12-02 14:02:09.408 28 ERROR cinder.api.v3.attachments raise exception.InvalidVolume(reason=msg)
2020-12-02 14:02:09.408 28 ERROR cinder.api.v3.attachments InvalidVolume: Invalid volume: duplicate connectors detected on volume c6697aa5-1e39-41e6-ae76-8e4906517f0a
2020-12-02 14:02:09.408 28 ERROR cinder.api.v3.attachments
2020-12-02 14:02:09.409 28 INFO cinder.api.openstack.wsgi [req-8be05ad0-c25f-4efd-bfca-ba23f17e10fb a6589c24b4724a8ca3a1206139b7b3a2 c40b5deebda84c2e9dfe6c2bf084318c - default default] HTTP exception thrown: Unable to update attachment.(Invalid volume: duplicate connectors detected on volume c6697aa5-1e39-41e6-ae76-8e4906517f0a).
2020-12-02 14:02:09.409 28 INFO cinder.api.openstack.wsgi [req-8be05ad0-c25f-4efd-bfca-ba23f17e10fb a6589c24b4724a8ca3a1206139b7b3a2 c40b5deebda84c2e9dfe6c2bf084318c - default default] http://10.148.59.10:8776/v3/c40b5deebda84c2e9dfe6c2bf084318c/attachments/0991b5d7-b263-41c9-b95b-b2c1bd637d0a returned with HTTP 500

tags: added: attachment exception status-code volume
Changed in cinder:
status: New → Triaged
importance: Undecided → Low
importance: Low → Medium
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to cinder (master)

Fix proposed to branch: master
Review: https://review.opendev.org/c/openstack/cinder/+/856041

Changed in cinder:
status: Triaged → In Progress
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.