From ee9ed0f7c6abf7c4847e6dc31f6d3d79b25b9d99 Mon Sep 17 00:00:00 2001 From: Sylvain Bauza Date: Wed, 25 Oct 2023 10:58:36 +0200 Subject: [PATCH] Fix rebuild compute RPC API exception for rolling-upgrades By I0d889691de1af6875603a9f0f174590229e7be18 we broke rebuild for Yoga or older computes. By I9660d42937ad62d647afc6be965f166cc5631392 we broke rebuild for Zed computes. Fixing this by making the parameters optional. Change-Id: I0ca04045f8ac742e2b50490cbe5efccaee45c5c0 Closed-Bug: #2040264 --- nova/compute/manager.py | 7 ++++--- .../functional/regressions/test_bug_2040264.py | 17 ++--------------- 2 files changed, 6 insertions(+), 18 deletions(-) diff --git a/nova/compute/manager.py b/nova/compute/manager.py index 59fa18ee53fb..d9363f60c41e 100644 --- a/nova/compute/manager.py +++ b/nova/compute/manager.py @@ -3747,7 +3747,7 @@ class ComputeManager(manager.Manager): bdms, recreate, on_shared_storage, preserve_ephemeral, migration, scheduled_node, limits, request_spec, accel_uuids, - reimage_boot_volume, target_state): + reimage_boot_volume=None, target_state=None): """Destroy and re-make this instance. A 'rebuild' effectively purges all existing data from the system and @@ -3781,8 +3781,9 @@ class ComputeManager(manager.Manager): :param accel_uuids: a list of cyborg ARQ uuids :param reimage_boot_volume: Boolean to specify whether the user has explicitly requested to rebuild a boot - volume - :param target_state: Set a target state for the evacuated instance. + volume or None if RPC version is <=6.0 + :param target_state: Set a target state for the evacuated instance or + None if RPC version is <=6.1. """ # recreate=True means the instance is being evacuated from a failed diff --git a/nova/tests/functional/regressions/test_bug_2040264.py b/nova/tests/functional/regressions/test_bug_2040264.py index 1de43b8a9207..c0e88c1154b5 100644 --- a/nova/tests/functional/regressions/test_bug_2040264.py +++ b/nova/tests/functional/regressions/test_bug_2040264.py @@ -11,7 +11,6 @@ # under the License. from nova.tests import fixtures as nova_fixtures -from nova.tests.functional.api import client from nova.tests.functional import integrated_helpers @@ -46,23 +45,11 @@ class ComputeVersion6xPinnedRpcTests(integrated_helpers._IntegratedTestBase): # We automatically pin to 6.0 if old computes are Yoga or older. def test_rebuild_instance_6_0(self): - e = self.assertRaises(client.OpenStackApiException, - self._test_rebuild_instance_with_compute_rpc_pin, '6.0') - self.assertEqual(500, e.response.status_code) - # NOTE(sbauza): This returns a TypeError because of - # 'reimage_boot_volume' and 'target_state' parameters missing from the - # rcpapi caller. - self.assertIn('TypeError', e.response.text) + self._test_rebuild_instance_with_compute_rpc_pin('6.0') # We automatically pin to 6.1 if old computes are Zed. def test_rebuild_instance_6_1(self): - e = self.assertRaises(client.OpenStackApiException, - self._test_rebuild_instance_with_compute_rpc_pin, '6.1') - self.assertEqual(500, e.response.status_code) - # NOTE(sbauza): This returns a TypeError because of - # 'reimage_boot_volume' and 'target_state' parameters missing from the - # rcpapi caller. - self.assertIn('TypeError', e.response.text) + self._test_rebuild_instance_with_compute_rpc_pin('6.1') # We automatically pin to 6.2 if old computes are 2023.1. def test_rebuild_instance_6_2(self):