Merge "Remove allocations when unshelve fails on host"

This commit is contained in:
Jenkins
2017-09-25 16:38:00 +00:00
committed by Gerrit Code Review
2 changed files with 11 additions and 6 deletions

View File

@@ -4531,9 +4531,17 @@ class ComputeManager(manager.Manager):
network_info=network_info,
block_device_info=block_device_info)
except Exception:
with excutils.save_and_reraise_exception():
with excutils.save_and_reraise_exception(logger=LOG):
LOG.exception('Instance failed to spawn',
instance=instance)
# Cleanup allocations created by the scheduler on this host
# since we failed to spawn the instance. We do this both if
# the instance claim failed with ComputeResourcesUnavailable
# or if we did claim but the spawn failed, because aborting the
# instance claim will not remove the allocations.
rt.reportclient.delete_allocation_for_instance(instance.uuid)
# FIXME: Umm, shouldn't we be rolling back volume connections
# and port bindings?
if image:
instance.image_ref = shelved_image_ref

View File

@@ -2582,8 +2582,5 @@ class ServerUnshelveSpawnFailTests(ProviderUsageBaseTestCase):
# assert allocations were removed from the host
usages = self._get_provider_usages(rp_uuid)
# FIXME: this is bug 1713796 where the allocations aren't cleaned up;
# remove once fixed
self.assertFlavorMatchesAllocation(self.flavor1, usages)
# self.assertFlavorMatchesAllocation(
# {'vcpus': 0, 'ram': 0, 'disk': 0}, usages)
self.assertFlavorMatchesAllocation(
{'vcpus': 0, 'ram': 0, 'disk': 0}, usages)