diff options
author | Balazs Gibizer <balazs.gibizer@est.tech> | 2020-02-10 15:48:04 +0100 |
---|---|---|
committer | Balazs Gibizer <balazs.gibizer@est.tech> | 2020-07-13 16:03:47 +0000 |
commit | 89312275607ea21e1c35a393ad1b00fe5591e30a (patch) | |
tree | bccac32e3167912374be264e380bdcd028b9c00f | |
parent | 618dd9bdc24b3a1de6a5581d4e7201efdf1f86bd (diff) | |
download | nova-89312275607ea21e1c35a393ad1b00fe5591e30a.tar.gz |
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 e65d4a131a7ebc02261f5df69fa1b394a502f268)
(cherry picked from commit e6b749dbdd735e2cd0054654b5da7a02280a080b)
(cherry picked from commit 405a35587a2291e3cf9eb4efc8f102c91bb4ef76)
(cherry picked from commit aeeab5d064492e112cd626a2988a6808250fb029)
(cherry picked from commit 9a073c9edc993525e896f67eeda1639a248fe2df)
-rw-r--r-- | nova/compute/manager.py | 7 | ||||
-rw-r--r-- | nova/tests/functional/regressions/test_bug_1862633.py | 13 |
2 files changed, 9 insertions, 11 deletions
diff --git a/nova/compute/manager.py b/nova/compute/manager.py index ede000bea4..7996c8f182 100644 --- a/nova/compute/manager.py +++ b/nova/compute/manager.py @@ -4731,10 +4731,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 rt.instance_claim(context, instance, node, limits): self.driver.spawn(context, instance, image_meta, injected_files=[], diff --git a/nova/tests/functional/regressions/test_bug_1862633.py b/nova/tests/functional/regressions/test_bug_1862633.py index e35e391417..ab22b32d19 100644 --- a/nova/tests/functional/regressions/test_bug_1862633.py +++ b/nova/tests/functional/regressions/test_bug_1862633.py @@ -62,7 +62,8 @@ class UnshelveNeutronErrorTest( } self.api.post_server_action(server['id'], req) 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/%s' % server['id']).body['allocations'] self.assertEqual(0, len(allocations)) @@ -87,14 +88,10 @@ class UnshelveNeutronErrorTest( self.api, server, {'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 - # 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)) |