POST to os-volume_attachments returns invalid 404

Bug #1062494 reported by Glen Campbell
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
OpenStack Compute (nova)
Fix Released
Low
Janis Gengeris

Bug Description

If you POST to os-volume_attachments but give the name of the volume instead of a UUID, it returns a 404 error; this is invalid HTTP. 404 means that the Request-URI has not been found. In fact, the Request-URI has been found, but a child attribute has been incorrectly specified. Some other error could should be used.

Here is sample debug output from nova client:

send: u'POST /v2/696206/servers/103b1f63-31ea-454d-ba63-4872a65c1b09/os-volume_attachments HTTP/1.1\r\nHost: dfw.servers.api.rackspacecloud.com\r\nContent-Length: 64\r\nx-auth-project-id: 696206\r\naccept-encoding: gzip, deflate\r\naccept: application/json\r\nx-auth-token: 801844be-8c8d-44d5-897f-05786b4e360a\r\nuser-agent: python-novaclient\r\ncontent-type: application/json\r\n\r\n{"volumeAttachment": {"device": null, "volumeId": "TESTVOLUME"}}'
reply: 'HTTP/1.1 404 Not Found\r\n'
header: Date: Fri, 05 Oct 2012 16:20:27 GMT
header: Content-Length: 78
header: Content-Type: application/json; charset=UTF-8
header: X-Compute-Request-Id: req-62383613-37fc-4891-aa67-dde01a708d1d
header: Server: Jetty(8.0.y.z-SNAPSHOT)
RESP:{'status': '404', 'content-length': '78', 'x-compute-request-id': 'req-62383613-37fc-4891-aa67-dde01a708d1d', 'server': 'Jetty(8.0.y.z-SNAPSHOT)', 'date': 'Fri, 05 Oct 2012 16:20:27 GMT', 'content-type': 'application/json; charset=UTF-8'} {"itemNotFound": {"message": "The resource could not be found.", "code": 404}}

DEBUG (shell:534) The resource could not be found. (HTTP 404) (Request-ID: req-62383613-37fc-4891-aa67-dde01a708d1d)
Traceback (most recent call last):
  File "/Library/Python/2.7/site-packages/novaclient/shell.py", line 531, in main
    OpenStackComputeShell().main(sys.argv[1:])
  File "/Library/Python/2.7/site-packages/novaclient/shell.py", line 467, in main
    args.func(self.cs, args)
  File "/Library/Python/2.7/site-packages/novaclient/v1_1/shell.py", line 1177, in do_volume_attach
    args.device)
  File "/Library/Python/2.7/site-packages/novaclient/v1_1/volumes.py", line 110, in create_server_volume
    body, "volumeAttachment")
  File "/Library/Python/2.7/site-packages/novaclient/base.py", line 148, in _create
    _resp, body = self.api.client.post(url, body=body)
  File "/Library/Python/2.7/site-packages/novaclient/client.py", line 242, in post
    return self._cs_request(url, 'POST', **kwargs)
  File "/Library/Python/2.7/site-packages/novaclient/client.py", line 226, in _cs_request
    **kwargs)
  File "/Library/Python/2.7/site-packages/novaclient/client.py", line 208, in _time_request
    resp, body = self.request(url, method, **kwargs)
  File "/Library/Python/2.7/site-packages/novaclient/client.py", line 202, in request
    raise exceptions.from_response(resp, body)
NotFound: The resource could not be found. (HTTP 404) (Request-ID: req-62383613-37fc-4891-aa67-dde01a708d1d)
ERROR: The resource could not be found. (HTTP 404) (Request-ID: req-62383613-37fc-4891-aa67-dde01a708d1d)

Chuck Short (zulcss)
Changed in nova:
importance: Undecided → Low
status: New → Triaged
Janis Gengeris (janisg)
Changed in nova:
assignee: nobody → Janis Gengeris (janisg)
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/18796

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

Reviewed: https://review.openstack.org/18796
Committed: http://github.com/openstack/nova/commit/2b619e271624eb84947a9a9596745d06efe81b08
Submitter: Jenkins
Branch: master

commit 2b619e271624eb84947a9a9596745d06efe81b08
Author: Janis Gengeris <email address hidden>
Date: Tue Jan 1 22:28:41 2013 +0200

    Adds os-volume_attachments 'volume_id' validation

    If you POST to os-volume_attachments but give the name of the volume
    instead of a UUID, it returns a 404 error; this is invalid HTTP.
    404 means that the Request-URI has not been found. In fact, the
    Request-URI has been found, but a child attribute has been incorrectly
    specified. Some other error could be used.

    This fixes the problem by returning 'BadRequest' in place of 'NotFound'.
    The 'volumeId' is checked to be a valid UUID string before moving
    further.

    Fixes bug #1062494

    Change-Id: Icc5dbc7ac94051514709997457cafb16e870bea9

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