Skip to content

Commit

Permalink
Avoid vm instance shutdown when power state is NOSTATE
Browse files Browse the repository at this point in the history
* nova/compute/manager.py (_sync_power_states): Log the condition
where we can retrieve the state from the hyperviser, rather than
stopping the VM.

Related grizzly commits are 95e7770 and ad101ce

Fixes bug: 1085771
Change-Id: I5fb9fdc6bcde729c00c4931960ed0de3b8fa189d
  • Loading branch information
Pádraig Brady committed Feb 21, 2013
1 parent 7ac3fe1 commit cb843f7
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
11 changes: 8 additions & 3 deletions nova/compute/manager.py
Expand Up @@ -2737,9 +2737,8 @@ def _sync_power_states(self, context):
pass
elif vm_state == vm_states.ACTIVE:
# The only rational power state should be RUNNING
if vm_power_state in (power_state.NOSTATE,
power_state.SHUTDOWN,
power_state.CRASHED):
if vm_power_state in (power_state.SHUTDOWN,
power_state.CRASHED):
LOG.warn(_("Instance shutdown by itself. Calling "
"the stop API."), instance=db_instance)
try:
Expand Down Expand Up @@ -2774,6 +2773,12 @@ def _sync_power_states(self, context):
# instrumentation is done. See bug 1097806 for details.
LOG.warn(_("Instance is paused unexpectedly. Ignore."),
instance=db_instance)
elif vm_power_state == power_state.NOSTATE:
# Occasionally, depending on the status of the hypervisor,
# which could be restarting for example, an instance may
# not be found. Therefore just log the condidtion.
LOG.warn(_("Instance is unexpectedly not found. Ignore."),
instance=db_instance)
elif vm_state == vm_states.STOPPED:
if vm_power_state not in (power_state.NOSTATE,
power_state.SHUTDOWN,
Expand Down
2 changes: 1 addition & 1 deletion nova/tests/compute/test_compute.py
Expand Up @@ -2313,7 +2313,7 @@ def test_run_kill_vm(self):
instances = db.instance_get_all(ctxt)
LOG.info(_("After force-killing instances: %s"), instances)
self.assertEqual(len(instances), 1)
self.assertEqual(task_states.STOPPING, instances[0]['task_state'])
self.assertEqual(instances[0]['task_state'], None)

def test_add_instance_fault(self):
exc_info = None
Expand Down

0 comments on commit cb843f7

Please sign in to comment.