Clean up allocation if unshelve fails due to neutron

When port binding update fails during unshelve of a shelve offloaded
instance compute manager has to catch the exception and clean up the
destination host allocation.

Change-Id: I4c3fbb213e023ac16efc0b8561f975a659311684
Closes-Bug: #1862633
(cherry picked from commit e65d4a131a)
(cherry picked from commit e6b749dbdd)
(cherry picked from commit 405a35587a)
(cherry picked from commit aeeab5d064)
This commit is contained in:
Balazs Gibizer 2020-02-10 15:48:04 +01:00 committed by Lee Yarwood
parent 779e88d5f2
commit 9a073c9edc
2 changed files with 9 additions and 11 deletions

View File

@ -5240,10 +5240,11 @@ class ComputeManager(manager.Manager):
utils.get_image_from_system_metadata( utils.get_image_from_system_metadata(
instance.system_metadata)) instance.system_metadata))
self.network_api.setup_instance_network_on_host(context, instance,
self.host)
network_info = self.network_api.get_instance_nw_info(context, instance)
try: try:
self.network_api.setup_instance_network_on_host(context, instance,
self.host)
network_info = self.network_api.get_instance_nw_info(
context, instance)
with rt.instance_claim(context, instance, node, limits): with rt.instance_claim(context, instance, node, limits):
self.driver.spawn(context, instance, image_meta, self.driver.spawn(context, instance, image_meta,
injected_files=[], injected_files=[],

View File

@ -62,7 +62,8 @@ class UnshelveNeutronErrorTest(
} }
self.api.post_server_action(server['id'], req) self.api.post_server_action(server['id'], req)
self._wait_for_server_parameter( self._wait_for_server_parameter(
self.api, server, {'status': 'SHELVED_OFFLOADED'}) self.api, server, {'status': 'SHELVED_OFFLOADED',
'OS-EXT-SRV-ATTR:host': None})
allocations = self.placement_api.get( allocations = self.placement_api.get(
'/allocations/%s' % server['id']).body['allocations'] '/allocations/%s' % server['id']).body['allocations']
self.assertEqual(0, len(allocations)) self.assertEqual(0, len(allocations))
@ -88,14 +89,10 @@ class UnshelveNeutronErrorTest(
self.api, self.api,
server, server,
{'status': 'SHELVED_OFFLOADED', {'status': 'SHELVED_OFFLOADED',
'OS-EXT-STS:task_state': None}) 'OS-EXT-STS:task_state': None,
'OS-EXT-SRV-ATTR:host': None})
# As the instance went back to offloaded state we expect no allocation # As the instance went back to offloaded state we expect no allocation
# allocations = self.placement_api.get(
# '/allocations/%s' % server['id']).body['allocations']
# self.assertEqual(0, len(allocations))
#
# but the allocation is leaked this is bug 1862633
allocations = self.placement_api.get( allocations = self.placement_api.get(
'/allocations/%s' % server['id']).body['allocations'] '/allocations/%s' % server['id']).body['allocations']
self.assertEqual(1, len(allocations)) self.assertEqual(0, len(allocations))