InstanceIsLocked Exception didn't raise

Bug #1266960 reported by Jay Lee
12
This bug affects 2 people
Affects Status Importance Assigned to Milestone
OpenStack Compute (nova)
Fix Released
Medium
jichenjc

Bug Description

When VM is locked by nova, VM API should not execute.
There are so many api that cannot be executed when vm is locked.
But When API is tried, nova raise inappropriate InstanceInvalidSate exception instead of InstanceIsLocked exception.
example)
$ nova reboot 9b4a0687-d1f5-4dac-a49e-f5c6d1f3e316
ERROR: Instance is in an invalid state for 'reboot' (HTTP 409) (Request-ID: req-8407d42d-9f0e-4c91-995b-35025251f209)
$ nova delete 9b4a0687-d1f5-4dac-a49e-f5c6d1f3e316
Instance is in an invalid state for 'delete' (HTTP 409) (Request-ID: req-f1b144b6-958e-4b19-84c7-fa641344d4d5)

This case is occured from so many compute api.
delete
reboot
rebuild
resize
shelve
pause
unpause
suspend
resume
rescue
unrescue
attach_volume
detach_volume
update_instance_metadata

InstanceInvalidState is used at many api to check state is appropriate,
but InstanceIsLocked inherited InstanceInvalidState, when vm is locked, api request return InstanceInvalidState instead of InstanceIsLocked.

So I suggest modify InstanceIsLocked inherit Invalid instead of InstanceInvalidState.
InstanceIsLocked(InstanceInvalidState) -> InstanceIsLocked(Invalid)

Tags: api
Revision history for this message
shihanzhang (shihanzhang) wrote :

this bug is already commited,the Bug #1256873

Revision history for this message
Jay Lee (hyangii) wrote :

I think this problem will be solve very easily.
just fix InstanceIsLocked(InstanceInvalidState) to InstanceIsLocked(Invalid) in exception.py
It doesn't need to fix any other sources.

but Bug #1256873(https://review.openstack.org/60128) looks very complicated.

What do you think about it?

Revision history for this message
huangtianhua (huangtianhua) wrote :

Thanks Jay:)

In my opinion:
1. If only fix InstanceIsLocked(InstanceInvalidState) to InstanceIsLocked(Invalid), the error code 400 will be raise, i think we should keep pace with other actions(such v3 admin actions) and to return 409 error code.

2. In my patch (https://review.openstack.org/60128), i add some tests so make it looks complicated :)

What do you think about?

Matt Riedemann (mriedem)
tags: added: api
Changed in nova:
status: New → Opinion
Revision history for this message
jichenjc (jichenjc) wrote :

In my opinion, https://bugs.launchpad.net/nova/+bug/1256873 only fix part of the problem, at least following should be fixed
rescue/unrescue
update_instance_metadata/delete_instance_metadata
should be updated

I will update them and add test cases

Changed in nova:
assignee: nobody → jichencom (jichenjc)
Revision history for this message
jichenjc (jichenjc) wrote :

let me know your opinion and suggestion, thanks

Changed in nova:
status: Opinion → New
assignee: jichencom (jichenjc) → nobody
jichenjc (jichenjc)
Changed in nova:
assignee: nobody → jichencom (jichenjc)
Revision history for this message
Jay Lee (hyangii) wrote :

Looks good to me, jichencom

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

Reviewed: https://review.openstack.org/71547
Committed: https://git.openstack.org/cgit/openstack/nova/commit/?id=73a441d4046a2609621180e84c78421999a6b4c3
Submitter: Jenkins
Branch: master

commit 73a441d4046a2609621180e84c78421999a6b4c3
Author: jichenjc <email address hidden>
Date: Sun Jan 26 22:54:35 2014 +0800

    Catch InstanceInLocked exception for rescue and instance metadata APIs

    When VM is locked by nova, VM API should not execute.
    There are so many api that cannot be executed when vm is locked.
    rescue/unrescue
    update_instance_metadata/delete_instance_metadata
    the above APIs should be updated to catch InstanceIsLocked exception

    Change-Id: Ic88f3d190894d4b65f54b34660efd9ae83fb0ee4
    Closes-Bug: #1266960

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