wrong methods can be called on nova APIs

Bug #1088530 reported by Sean Dague
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
OpenStack Compute (nova)
Fix Released
Medium
Guangyu Suo

Bug Description

All of our REST resources are setup with the route.mapper (when you dig deep enough), which registers a set of default methods on all the resources in nova. It creates 5 methods:

GET /resource - def index
POST /resource- def create
PUT /resource/{id} - def update
DELETE /resource/{id} - def delete
GET /resource/{id} - def show

Should a resource not support all those actions, the default behavior ends up returning 200 with some boilerplate HTML (a good example is doing a DELETE on /v2/ for nova). There doesn't seem to be any side effects from this action, however for correctness we should do the right thing here.

The correct behavior would be the return of an HTTP 405 (method not allowed) in these cases.

Sean Dague (sdague)
Changed in nova:
importance: Undecided → Medium
Michael Still (mikal)
Changed in nova:
status: New → Triaged
Guangyu Suo (yugsuo)
Changed in nova:
assignee: nobody → yugsuo (yugsuo)
Revision history for this message
Guangyu Suo (yugsuo) wrote :

Hello, I found where is the problem :

in nova/nova/api/openstack/compute/__init__.py, the APIRouter class

mapper.connect("versions", "/",
                        controller=self.resources['versions'],
                        action='show')

it should add request method conditions like this:

mapper.connect("versions", "/",
                        controller=self.resources['versions'],
                        action='show',
                        conditions={"method": ['GET']})

But this changes the result from HTTP 200 OK to HTTP 404 Not Found, not 405.

And only versions have this problem, others are normal.

You can test like this:

$ curl -X DELETE -v -H "X-Auth-Token:$AUTH_TOKEN" http://192.168.1.100:8774/v2/

Guangyu Suo (yugsuo)
Changed in nova:
status: Triaged → In Progress
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/18771

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

Reviewed: https://review.openstack.org/18771
Committed: http://github.com/openstack/nova/commit/1ab59c999e918e86c4bd0224db9ef98b585138a4
Submitter: Jenkins
Branch: master

commit 1ab59c999e918e86c4bd0224db9ef98b585138a4
Author: yugsuo <email address hidden>
Date: Mon Dec 31 16:03:54 2012 +0800

    Add conditions in compute APIRouter

    The Route of versions should add HTTP GET methods conditions, because
    it only has a 'show' action, thus other methods will not match.

    Fixes bug 1088530

    Change-Id: Ib21381324cf7067015d0a6e36a0f0292eb902fe9

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.