Merge "Handle missing dst_node parameter in zone_migration"

This commit is contained in:
Zuul
2025-05-20 17:14:29 +00:00
committed by Gerrit Code Review
3 changed files with 18 additions and 6 deletions

View File

@@ -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.

View File

@@ -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,

View File

@@ -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(