Merge "Failure during termination should always leave state as Error(Deleting)"

This commit is contained in:
Jenkins
2014-01-31 02:08:15 +00:00
committed by Gerrit Code Review
2 changed files with 14 additions and 12 deletions

View File

@@ -2019,7 +2019,6 @@ class ComputeManager(manager.Manager):
system_meta)
@wrap_exception()
@reverts_task_state
@wrap_instance_event
@wrap_instance_fault
def terminate_instance(self, context, instance, bdms, reservations):
@@ -2030,12 +2029,16 @@ class ComputeManager(manager.Manager):
try:
self._delete_instance(context, instance, bdms,
reservations=reservations)
except exception.InstanceTerminationFailure as error:
LOG.exception(_('Setting instance vm_state to ERROR'),
instance=instance)
self._set_instance_error_state(context, instance['uuid'])
except exception.InstanceNotFound as e:
LOG.warn(e, instance=instance)
except exception.InstanceNotFound:
LOG.info(_("Instance disappeared during terminate"),
instance=instance)
except Exception as error:
# As we're trying to delete always go to Error if something
# goes wrong that _delete_instance can't handle.
with excutils.save_and_reraise_exception():
LOG.exception(_('Setting instance vm_state to ERROR'),
instance=instance)
self._set_instance_error_state(context, instance['uuid'])
do_terminate_instance(instance, bdms)

View File

@@ -3327,8 +3327,10 @@ class ComputeTestCase(BaseTestCase):
self.stubs.Set(self.compute, '_delete_instance',
fake_delete_instance)
self.compute.terminate_instance(self.context,
self._objectify(instance), [], [])
self.assertRaises(exception.InstanceTerminationFailure,
self.compute.terminate_instance,
self.context,
self._objectify(instance), [], [])
instance = db.instance_get_by_uuid(self.context, instance['uuid'])
self.assertEqual(instance['vm_state'], vm_states.ERROR)
@@ -3503,9 +3505,6 @@ class ComputeTestCase(BaseTestCase):
'reboot_type': 'SOFT'}),
("stop_instance", task_states.POWERING_OFF),
("start_instance", task_states.POWERING_ON),
("terminate_instance", task_states.DELETING,
{'bdms': [],
'reservations': []}),
("soft_delete_instance", task_states.SOFT_DELETING,
{'reservations': []}),
("restore_instance", task_states.RESTORING),