Unhelpful error message when trying to force detach and content-type header is missing

Bug #1749983 reported by Matt Riedemann
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Cinder
Fix Released
Low
Matt Riedemann
OpenStack Compute (nova)
Confirmed
Low
Unassigned

Bug Description

I was trying to force detach a volume using curl like so:

curl -d '{"os-force_detach": {}}' -H "accept: application/json" -H "x-auth-token: $token" http://199.204.45.19/volume/v3/e9d773beeef2435eb59f7c6eeaf685a9/volumes/126c8d4b-c582-484a-8c09-fe901a7dc17f/action

And I'd get this error message back:

{"badRequest": {"message": "There is no such action: None", "code": 400}}

When I dug into the cinder-api logs, I saw this:

Feb 16 16:08:49 queens <email address hidden>[1549]: DEBUG cinder.api.openstack.wsgi [None req-c7279a60-f7ba-4a11-98f2-8fa2b2ec281d demo demo] Unrecognized Content-Type provided in request {{(pid=1723) get_body /opt/stack/cinder/cinder/api/openstack/wsgi.py:724}}

Changing the 'accept' header to 'content-type' fixed it:

 curl -d '{"os-force_detach": {}}' -H "content-type: application/json" -H "x-auth-token: $token" http://199.204.45.19/volume/v3/e9d773beeef2435eb59f7c6eeaf685a9/volumes/126c8d4b-c582-484a-8c09-fe901a7dc17f/action

I get a policy error since I'm not an admin (default policy rule on this API is admin-only), but it went through properly:

{"forbidden": {"message": "Policy doesn't allow volume_extension:volume_admin_actions:force_detach to be performed.", "code": 403}}

The bug is that the missing content-type results in a very unhelpful error message.

Tags: api usability
Matt Riedemann (mriedem)
Changed in cinder:
importance: Undecided → Low
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/545378

Changed in cinder:
assignee: nobody → Matt Riedemann (mriedem)
status: New → In Progress
Revision history for this message
Matt Riedemann (mriedem) wrote :

Added nova since it has the exact same code.

Changed in nova:
status: New → Confirmed
importance: Undecided → Low
assignee: nobody → Matt Riedemann (mriedem)
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/545382

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

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

commit c100c8f1888f8963ed5cf81661e52889d765d2b2
Author: Matt Riedemann <email address hidden>
Date: Fri Feb 16 11:31:10 2018 -0500

    Provide a hint when performing a volume action can't find the method

    There is no CLI for the os-force_detach volume action API, and while
    making a request for it with curl, I mistakenly used the Accept
    header rather than the Content-Type header and got the unhelpful
    error message:

      "There is no such action: None"

    We can provide some simple details in the error message about
    making sure the request body is correct and that the Content-Type
    header is specified to help the user.

    Change-Id: I00600c297e39c0dd097f9da80b1dccb38ee3d235
    Closes-Bug: #1749983

Changed in cinder:
status: In Progress → Fix Released
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Change abandoned on nova (master)

Change abandoned by Matt Riedemann (<email address hidden>) on branch: master
Review: https://review.openstack.org/545382

Matt Riedemann (mriedem)
Changed in nova:
status: In Progress → Confirmed
assignee: Matt Riedemann (mriedem) → nobody
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix included in openstack/cinder 13.0.0.0b1

This issue was fixed in the openstack/cinder 13.0.0.0b1 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.