From f4bfb105252fe674562ecc4a4c138603d60dd72d Mon Sep 17 00:00:00 2001 From: "Chandan Kumar (raukadah)" Date: Fri, 25 Apr 2025 09:45:38 +0530 Subject: [PATCH] [host_maintenance] Pass des hostname in add_action solution Currently we are passing src_node and des_node uuid when we try to run migrate action. In the watcher-applier log, migration fails with following exception ``` Nova client exception occurred while live migrating instance Exception: Compute host could not be found ``` Based on https://github.com/openstack/watcher/blob/57f55190ff4a6e0df06ae2affba5b4f633ef7c48/watcher/applier/actions/migration.py#L122 and https://github.com/openstack/watcher/blob/57f55190ff4a6e0df06ae2affba5b4f633ef7c48/watcher/common/nova_helper.py#L322, live_migrate_instance expects destination hostname not uuid. This cr replaces dest_node uuid to hostname. Closes-Bug: #2109309 Change-Id: I3911ff24ea612f69dddae5eab15fabb4891f938d Signed-off-by: Chandan Kumar (raukadah) (cherry picked from commit 278cb7e98c3a23069d0913f3e4a240c4679b79d9) --- .../strategy/strategies/host_maintenance.py | 2 +- .../strategy/strategies/test_host_maintenance.py | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/watcher/decision_engine/strategy/strategies/host_maintenance.py b/watcher/decision_engine/strategy/strategies/host_maintenance.py index db9b1e217..ddf4335d8 100644 --- a/watcher/decision_engine/strategy/strategies/host_maintenance.py +++ b/watcher/decision_engine/strategy/strategies/host_maintenance.py @@ -195,7 +195,7 @@ class HostMaintenance(base.HostMaintenanceBaseStrategy): 'source_node': src_node.uuid, 'resource_name': instance.name} if des_node: - params['destination_node'] = des_node.uuid + params['destination_node'] = des_node.hostname self.solution.add_action(action_type=self.INSTANCE_MIGRATION, resource_id=instance.uuid, input_parameters=params) diff --git a/watcher/tests/decision_engine/strategy/strategies/test_host_maintenance.py b/watcher/tests/decision_engine/strategy/strategies/test_host_maintenance.py index d941f24f7..f8080760c 100644 --- a/watcher/tests/decision_engine/strategy/strategies/test_host_maintenance.py +++ b/watcher/tests/decision_engine/strategy/strategies/test_host_maintenance.py @@ -111,7 +111,7 @@ class TestHostMaintenance(TestBaseStrategy): self.strategy.instance_migration(instance_0, node_0, node_1) self.assertEqual(1, len(self.strategy.solution.actions)) expected = [{'action_type': 'migrate', - 'input_parameters': {'destination_node': node_1.uuid, + 'input_parameters': {'destination_node': node_1.hostname, 'source_node': node_0.uuid, 'migration_type': 'live', 'resource_id': instance_0.uuid, @@ -144,14 +144,14 @@ class TestHostMaintenance(TestBaseStrategy): self.strategy.host_migration(node_0, node_1) self.assertEqual(2, len(self.strategy.solution.actions)) expected = [{'action_type': 'migrate', - 'input_parameters': {'destination_node': node_1.uuid, + 'input_parameters': {'destination_node': node_1.hostname, 'source_node': node_0.uuid, 'migration_type': 'live', 'resource_id': instance_0.uuid, 'resource_name': instance_0.name }}, {'action_type': 'migrate', - 'input_parameters': {'destination_node': node_1.uuid, + 'input_parameters': {'destination_node': node_1.hostname, 'source_node': node_0.uuid, 'migration_type': 'live', 'resource_id': instance_1.uuid, @@ -213,7 +213,7 @@ class TestHostMaintenance(TestBaseStrategy): 'disabled_reason': 'watcher_maintaining'}}, {'action_type': 'migrate', 'input_parameters': { - 'destination_node': node_3.uuid, + 'destination_node': node_3.hostname, 'source_node': node_2.uuid, 'migration_type': 'live', 'resource_id': instance_4.uuid,