422 HTTP status code on several actions

Bug #1204999 reported by Attila Fazekas on 2013-07-25
14
This bug affects 3 people
Affects Status Importance Assigned to Milestone
OpenStack Compute (nova)
Undecided
Matt Riedemann

Bug Description

Several actions like 'suspend', 'resume' ,'pause', 'unpause' response with 422 Unprocessable Entity (WebDAV; RFC 4918) status code, when the server does not exists or deleted.

The request URL contains the server UUID, so the 404 response as with the other server actions are more logical, all server action should behave in the same way in the server not found situation.

This situations are not tested by tempest now, and probably will not be, until the 422 claimed as expected status code, or it changes to 404.

FIXME: The stable API policy allows to change these status codes in this situation.

Tags: api Edit Tag help
Attila Fazekas (afazekas) wrote :

A basic simple script to reproduce is attached.

melanie witt (melwitt) on 2013-08-01
tags: added: api
Matt Riedemann (mriedem) wrote :

This is what I see for hits in nova.api.openstack.compute.contrib.admin_actions:

62: raise exc.HTTPUnprocessableEntity() - pause
79: raise exc.HTTPUnprocessableEntity() - unpause
96: raise exc.HTTPUnprocessableEntity() - suspend
113: raise exc.HTTPUnprocessableEntity() - resume
143: raise exc.HTTPUnprocessableEntity() - reset network
159: raise exc.HTTPUnprocessableEntity() - inject network info
175: raise exc.HTTPUnprocessableEntity() - lock
191: raise exc.HTTPUnprocessableEntity() - unlock
329: raise exc.HTTPUnprocessableEntity() - reset state

I'm not sure I follow this statement though:

"The stable API policy allows to change these status codes in this situation."

That means we're OK to change the existing API for this? I'm sort of new to the rules on stable APIs, can you point to a doc or something that talks about that policy and if changing this is allowed?

Matt Riedemann (mriedem) wrote :

Correction, actually these do handle InstanceNotFound and convert to HTTPNotFound:

159: raise exc.HTTPUnprocessableEntity() - inject network info
175: raise exc.HTTPUnprocessableEntity() - lock
191: raise exc.HTTPUnprocessableEntity() - unlock
329: raise exc.HTTPUnprocessableEntity() - reset state

That leaves pause/unpause/suspend/resume/reset_network that should do the same.

Matt Riedemann (mriedem) wrote :

I found this wiki page on what's OK and not OK for API changes (generally):

https://wiki.openstack.org/wiki/APIChangeGuidelines#Generally_Considered_OK

This is the last bullet in that section:

"Changing an error response code to be more accurate"

I think that fits this bug. I'm pushing up a change.

Changed in nova:
assignee: nobody → Matt Riedemann (mriedem)

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

Changed in nova:
status: New → In Progress

Reviewed: https://review.openstack.org/40070
Committed: http://github.com/openstack/nova/commit/43ad0a2b1c7dea2c6f8888b28a61857c81067a16
Submitter: Jenkins
Branch: master

commit 43ad0a2b1c7dea2c6f8888b28a61857c81067a16
Author: Matt Riedemann <email address hidden>
Date: Sat Aug 3 13:15:12 2013 -0700

    Raise 404 when instance not found in admin_actions API

    The pause/unpause/suspend/resume/reset_network admin action APIs do not
    handle the case where the instance in the request is not found and they
    raise HTTPUnprocessableEntity (code 422) instead. There are several
    other operations in the same API which handle the 404 case and translate
    it correctly, this patch cleans up the rest.

    Closes-Bug: #1204999

    Change-Id: If54d6be99db55b4f99da11fe75c14bf21685e809

Changed in nova:
status: In Progress → Fix Committed
Thierry Carrez (ttx) on 2013-09-05
Changed in nova:
milestone: none → havana-3
status: Fix Committed → Fix Released
Thierry Carrez (ttx) on 2013-10-17
Changed in nova:
milestone: havana-3 → 2013.2
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers

Bug attachments