diff --git a/releasenotes/notes/zone-migration-missing-dst-node-bd0377af1f1ed245.yaml b/releasenotes/notes/zone-migration-missing-dst-node-bd0377af1f1ed245.yaml new file mode 100644 index 000000000..0cfaf4d9b --- /dev/null +++ b/releasenotes/notes/zone-migration-missing-dst-node-bd0377af1f1ed245.yaml @@ -0,0 +1,9 @@ +--- +fixes: + - | + The zone migration strategy no longer requires a dst_node to be passed. + When unspecified, the Nova scheduler will select an appropriate host automatically. + This brings the implementation of the strategy in line with the the api schema + where dest_node is optional. + + See: https://bugs.launchpad.net/watcher/+bug/2108988 for more details. diff --git a/watcher/decision_engine/strategy/strategies/zone_migration.py b/watcher/decision_engine/strategy/strategies/zone_migration.py index 16dd2f0d9..5b6e42888 100644 --- a/watcher/decision_engine/strategy/strategies/zone_migration.py +++ b/watcher/decision_engine/strategy/strategies/zone_migration.py @@ -444,9 +444,12 @@ class ZoneMigration(base.ZoneMigrationBaseStrategy): def _live_migration(self, instance, src_node, dst_node): parameters = {"migration_type": "live", - "destination_node": dst_node, "source_node": src_node, "resource_name": instance.name} + if dst_node: + # if dst_node is None, do not add it to the parameters for the + # migration action, and let Nova figure out the destination node + parameters["destination_node"] = dst_node self.solution.add_action( action_type="migrate", resource_id=instance.id, @@ -455,9 +458,12 @@ class ZoneMigration(base.ZoneMigrationBaseStrategy): def _cold_migration(self, instance, src_node, dst_node): parameters = {"migration_type": "cold", - "destination_node": dst_node, "source_node": src_node, "resource_name": instance.name} + if dst_node: + # if dst_node is None, do not add it to the parameters for the + # migration action, and let Nova figure out the destination node + parameters["destination_node"] = dst_node self.solution.add_action( action_type="migrate", resource_id=instance.id, diff --git a/watcher/tests/decision_engine/strategy/strategies/test_zone_migration.py b/watcher/tests/decision_engine/strategy/strategies/test_zone_migration.py index 5127f9794..0b3f72db5 100644 --- a/watcher/tests/decision_engine/strategy/strategies/test_zone_migration.py +++ b/watcher/tests/decision_engine/strategy/strategies/test_zone_migration.py @@ -259,10 +259,7 @@ class TestZoneMigration(TestBaseStrategy): migration_params = solution.actions[0]['input_parameters'] # since we have not passed 'dst_node' in the input, we should not have # a destination_node in the generated migration action - # self.assertNotIn('destination_node', migration_params) - # temporarily make the test pass, delete and use the above assert in - # followup - self.assertIsNone(migration_params['destination_node']) + self.assertNotIn('destination_node', migration_params) def test_execute_cold_migrate_instance(self): instance_on_src1 = self.fake_instance(