diff options
| author | Jenkins <jenkins@review.openstack.org> | 2012-07-26 21:50:33 +0000 |
|---|---|---|
| committer | Gerrit Code Review <review@openstack.org> | 2012-07-26 21:50:33 +0000 |
| commit | c8ee0c36e5e25c95403e2a49e989c2fcf447f7ff (patch) | |
| tree | 607e4f6b14f0f6183e465d891c22f78cf5bb0d42 /nova | |
| parent | 01d1e4937e175bb08de853719e0ffb9f9c56aa61 (diff) | |
| parent | 5974c441bd538897bd4547e6a05ee27216461d97 (diff) | |
| download | nova-c8ee0c36e5e25c95403e2a49e989c2fcf447f7ff.tar.gz nova-c8ee0c36e5e25c95403e2a49e989c2fcf447f7ff.tar.xz nova-c8ee0c36e5e25c95403e2a49e989c2fcf447f7ff.zip | |
Merge "Ensure instance is moved to ERROR on suspend failure"
Diffstat (limited to 'nova')
| -rw-r--r-- | nova/compute/manager.py | 3 | ||||
| -rw-r--r-- | nova/tests/compute/test_compute.py | 17 |
2 files changed, 19 insertions, 1 deletions
diff --git a/nova/compute/manager.py b/nova/compute/manager.py index 55cff40d0..559d7c33d 100644 --- a/nova/compute/manager.py +++ b/nova/compute/manager.py @@ -1793,7 +1793,8 @@ class ComputeManager(manager.SchedulerDependentManager): instance = self.db.instance_get_by_uuid(context, instance_uuid) LOG.audit(_('Suspending'), context=context, instance=instance) - self.driver.suspend(instance) + with self.error_out_instance_on_exception(context, instance['uuid']): + self.driver.suspend(instance) current_power_state = self._get_power_state(context, instance) self._instance_update(context, diff --git a/nova/tests/compute/test_compute.py b/nova/tests/compute/test_compute.py index 892675a77..603ef23f2 100644 --- a/nova/tests/compute/test_compute.py +++ b/nova/tests/compute/test_compute.py @@ -508,6 +508,23 @@ class ComputeTestCase(BaseTestCase): self.compute.resume_instance(self.context, instance_uuid) self.compute.terminate_instance(self.context, instance_uuid) + def test_suspend_error(self): + """Ensure vm_state is ERROR when suspend error occurs""" + def fake(*args, **kwargs): + raise test.TestingException() + self.stubs.Set(self.compute.driver, 'suspend', fake) + + instance = self._create_fake_instance() + instance_uuid = instance['uuid'] + self.compute.run_instance(self.context, instance_uuid) + self.assertRaises(test.TestingException, + self.compute.suspend_instance, + self.context, + instance=jsonutils.to_primitive(instance)) + instance = db.instance_get_by_uuid(self.context, instance_uuid) + self.assertEqual(instance['vm_state'], vm_states.ERROR) + self.compute.terminate_instance(self.context, instance_uuid) + def test_rebuild(self): """Ensure instance can be rebuilt""" instance = self._create_fake_instance() |
