summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--nova/compute/manager.py5
-rw-r--r--nova/tests/compute/test_compute.py29
2 files changed, 34 insertions, 0 deletions
diff --git a/nova/compute/manager.py b/nova/compute/manager.py
index a4f17ee3d..c894040a6 100644
--- a/nova/compute/manager.py
+++ b/nova/compute/manager.py
@@ -463,6 +463,11 @@ class ComputeManager(manager.SchedulerDependentManager):
except NotImplementedError:
LOG.warning(_('Hypervisor driver does not support '
'resume guests'), instance=instance)
+ except Exception:
+ # NOTE(vish): The instance failed to resume, so we set the
+ # instance to error and attempt to continue.
+ LOG.warning(_('Failed to resume instance'), instance=instance)
+ self._set_instance_error_state(context, instance['uuid'])
elif drv_state == power_state.RUNNING:
# VMwareAPI drivers will raise an exception
diff --git a/nova/tests/compute/test_compute.py b/nova/tests/compute/test_compute.py
index 40bc8d148..3deb100f6 100644
--- a/nova/tests/compute/test_compute.py
+++ b/nova/tests/compute/test_compute.py
@@ -3249,6 +3249,35 @@ class ComputeTestCase(BaseTestCase):
self.mox.VerifyAll()
self.mox.UnsetStubs()
+ def test_init_instance_failed_resume_sets_error(self):
+ instance = {
+ 'uuid': 'fake-uuid',
+ 'info_cache': None,
+ 'power_state': power_state.RUNNING,
+ 'vm_state': vm_states.ACTIVE,
+ }
+ self.flags(resume_guests_state_on_host_boot=True)
+ self.mox.StubOutWithMock(self.compute, '_get_power_state')
+ self.mox.StubOutWithMock(self.compute.driver, 'plug_vifs')
+ self.mox.StubOutWithMock(self.compute.driver,
+ 'resume_state_on_host_boot')
+ self.mox.StubOutWithMock(self.compute,
+ '_get_instance_volume_block_device_info')
+ self.mox.StubOutWithMock(self.compute,
+ '_set_instance_error_state')
+ self.compute._get_power_state(mox.IgnoreArg(),
+ instance).AndReturn(power_state.SHUTDOWN)
+ self.compute.driver.plug_vifs(instance, mox.IgnoreArg())
+ self.compute._get_instance_volume_block_device_info(mox.IgnoreArg(),
+ instance['uuid']).AndReturn('fake-bdm')
+ self.compute.driver.resume_state_on_host_boot(mox.IgnoreArg(),
+ instance, mox.IgnoreArg(),
+ 'fake-bdm').AndRaise(test.TestingException)
+ self.compute._set_instance_error_state(mox.IgnoreArg(),
+ instance['uuid'])
+ self.mox.ReplayAll()
+ self.compute._init_instance('fake-context', instance)
+
def test_get_instances_on_driver(self):
fake_context = context.get_admin_context()