500 response received when trying to create volume attachment when volume is in-use

Bug #1741112 reported by Matt Riedemann
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Cinder
Fix Released
Medium
Matt Riedemann
Nominated for Pike by Matt Riedemann

Bug Description

Using latest nova/cinder/devstack from queens master as of Jan 02 2018.

I create a multiattach=False volume and two server instances. I attach the volume to the first instance, it's OK. I tried attaching the same volume to the second instance and it fails. I expected it to fail, but it fails with a 500 error from the Cinder API, which nova doesn't expect so I get a 500 error from Nova's API.

nova-api logs: http://paste.openstack.org/show/637525/

This is the stacktrace from the cinder-api logs:

hments [req-173ee27b-ccec-4ba8-af31-11f030319b02 req-3411a6b3-b8c3-4bef-89a0-dc750d2ec60d demo demo] Unable to create attachment for volume (Invalid volume: Vo
hments Traceback (most recent call last):
hments File "/opt/stack/cinder/cinder/api/v3/attachments.py", line 172, in create
hments connector=connector))
hments File "/opt/stack/cinder/cinder/volume/api.py", line 2068, in attachment_create
hments instance_uuid)
hments File "/opt/stack/cinder/cinder/volume/api.py", line 2049, in _attachment_reserve
hments raise exception.InvalidVolume(reason=msg)
hments InvalidVolume: Invalid volume: Volume 373c2a29-f6e7-4931-adda-6b87a193e9f9 status must be available or downloading
hments
.wsgi [req-173ee27b-ccec-4ba8-af31-11f030319b02 req-3411a6b3-b8c3-4bef-89a0-dc750d2ec60d demo demo] HTTP exception thrown: Unable to create attachment for volu

I would have expected the ResourceExceptionHandler code in cinder-api's wsgi stack to have handled the InvalidVolume being raised up and converted that to a 400 BadRequest, but it doesn't appear to be happening.

Tags: api
Revision history for this message
Matt Riedemann (mriedem) wrote :

This tempest test also shows the 500 response https://review.openstack.org/#/c/459623/.

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to cinder (master)

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

Changed in cinder:
assignee: nobody → Matt Riedemann (mriedem)
status: New → In Progress
Matt Riedemann (mriedem)
Changed in cinder:
importance: Undecided → Medium
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to cinder (stable/pike)

Fix proposed to branch: stable/pike
Review: https://review.openstack.org/531265

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Change abandoned on cinder (stable/pike)

Change abandoned by Matt Riedemann (<email address hidden>) on branch: stable/pike
Review: https://review.openstack.org/531265
Reason: Actually we probably don't care about this on Pike. Nova only uses the new attachments API when 3.44 is available which wasn't in Pike, so we wouldn't hit this from the Nova side in Pike.

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to cinder (master)

Reviewed: https://review.openstack.org/531011
Committed: https://git.openstack.org/cgit/openstack/cinder/commit/?id=727e334950c672b9309ad6a1394488dbdc13952f
Submitter: Zuul
Branch: master

commit 727e334950c672b9309ad6a1394488dbdc13952f
Author: Matt Riedemann <email address hidden>
Date: Wed Jan 3 15:51:37 2018 -0500

    Handle InvalidVolume when creating a volume attachment

    If you try to attach a non-multiattach volume to more than
    once instance using the 3.27 volume attachments API, the volume
    API would return a 500 response because the volume is in-use.

    This translates to a 500 in the compute API because nova isn't
    expecting a random client exception.

    Treat this like how os-reserve could fail in the same situation
    and handle InvalidVolume which will be converted to an HTTPBadRequest
    by ResourceExceptionHandler elsewhere in the WSGi stack.

    Change-Id: I1a8068043159b034d700419675af87fc17e1faf5
    Closes-Bug: #1741112

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

This issue was fixed in the openstack/cinder 12.0.0.0b3 development milestone.

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.