Merge "Don't try to restore VM's in state ERROR."
This commit is contained in:
commit
290929e557
|
@ -628,9 +628,15 @@ class ComputeManager(manager.Manager):
|
|||
def _init_instance(self, context, instance):
|
||||
'''Initialize this instance during service init.'''
|
||||
|
||||
# instance was supposed to shut down - don't attempt
|
||||
# recovery in any case
|
||||
if instance.vm_state == vm_states.SOFT_DELETED:
|
||||
# Instances that are shut down, or in an error state can not be
|
||||
# initialized and are not attempted to be recovered. The exception
|
||||
# to this are instances that are in RESIZE_MIGRATING, which are
|
||||
# attempted recovery further down.
|
||||
if (instance.vm_state == vm_states.SOFT_DELETED or
|
||||
(instance.vm_state == vm_states.ERROR and
|
||||
instance.task_state != task_states.RESIZE_MIGRATING)):
|
||||
LOG.debug(_("Instance is in %s state."),
|
||||
instance.vm_state, instance=instance)
|
||||
return
|
||||
|
||||
if instance.vm_state == vm_states.DELETED:
|
||||
|
|
|
@ -430,6 +430,16 @@ class ComputeManagerUnitTestCase(test.NoDBTestCase):
|
|||
instance.task_state = task_states.IMAGE_SNAPSHOT
|
||||
self._test_init_instance_cleans_image_states(instance)
|
||||
|
||||
def test_init_instance_errors_when_not_migrating(self):
|
||||
instance = instance_obj.Instance(self.context)
|
||||
instance.uuid = 'foo'
|
||||
instance.vm_state = vm_states.ERROR
|
||||
instance.task_state = task_states.IMAGE_UPLOADING
|
||||
self.mox.StubOutWithMock(compute_utils, 'get_nw_info_for_instance')
|
||||
self.mox.ReplayAll()
|
||||
self.compute._init_instance(self.context, instance)
|
||||
self.mox.VerifyAll()
|
||||
|
||||
def test_get_instances_on_driver(self):
|
||||
fake_context = context.get_admin_context()
|
||||
|
||||
|
|
Loading…
Reference in New Issue