Merge "Allow deletion of instance with failed vol cleanup"

This commit is contained in:
Jenkins 2012-09-24 14:59:56 +00:00 committed by Gerrit Code Review
commit 301cb6869d
2 changed files with 25 additions and 1 deletions

View File

@ -887,7 +887,19 @@ class ComputeManager(manager.SchedulerDependentManager):
self.db.instance_info_cache_delete(context, instance_uuid)
self._notify_about_instance_usage(context, instance, "delete.start")
self._shutdown_instance(context, instance)
self._cleanup_volumes(context, instance_uuid)
# NOTE(vish): We have already deleted the instance, so we have
# to ignore problems cleaning up the volumes. It would
# be nice to let the user know somehow that the volume
# deletion failed, but it is not acceptable to have an
# instance that can not be deleted. Perhaps this could
# be reworked in the future to set an instance fault
# the first time and to only ignore the failure if the
# instance is already in ERROR.
try:
self._cleanup_volumes(context, instance_uuid)
except Exception as exc:
LOG.warn(_("Ignoring volume cleanup failure due to %s") % exc,
instance_uuid=instance_uuid)
# if a delete task succeed, always update vm state and task state
# without expecting task state to be DELETING
instance = self._instance_update(context,

View File

@ -1329,6 +1329,18 @@ class ComputeTestCase(BaseTestCase):
self.compute.terminate_instance(self.context,
instance=jsonutils.to_primitive(instance))
def test_delete_instance_succedes_on_volume_fail(self):
instance = self._create_fake_instance()
def fake_cleanup_volumes(context, instance):
raise test.TestingException()
self.stubs.Set(self.compute, '_cleanup_volumes',
fake_cleanup_volumes)
self.compute._delete_instance(self.context,
instance=jsonutils.to_primitive(instance))
def test_instance_termination_exception_sets_error(self):
"""Test that we handle InstanceTerminationFailure
which is propagated up from the underlying driver.