From e65d4a131a7ebc02261f5df69fa1b394a502f268 Mon Sep 17 00:00:00 2001 From: Balazs Gibizer Date: Mon, 10 Feb 2020 15:48:04 +0100 Subject: [PATCH] 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 --- nova/compute/manager.py | 7 ++++--- nova/tests/functional/regressions/test_bug_1862633.py | 7 +------ 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/nova/compute/manager.py b/nova/compute/manager.py index 237d9d94d3b9..fdf8d4e7756f 100644 --- a/nova/compute/manager.py +++ b/nova/compute/manager.py @@ -6470,10 +6470,11 @@ class ComputeManager(manager.Manager): utils.get_image_from_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: + self.network_api.setup_instance_network_on_host(context, instance, + self.host) + network_info = self.network_api.get_instance_nw_info( + context, instance) with self.rt.instance_claim(context, instance, node, allocations, limits): self.driver.spawn(context, instance, image_meta, diff --git a/nova/tests/functional/regressions/test_bug_1862633.py b/nova/tests/functional/regressions/test_bug_1862633.py index 9990734b3614..5d3826a39110 100644 --- a/nova/tests/functional/regressions/test_bug_1862633.py +++ b/nova/tests/functional/regressions/test_bug_1862633.py @@ -82,11 +82,6 @@ class UnshelveNeutronErrorTest( 'OS-EXT-STS:task_state': None}) # 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/%s' % server['id']).body['allocations'] - self.assertEqual(1, len(allocations)) + self.assertEqual(0, len(allocations))