Merge "Fix zone migration instance not found issue" into stable/2025.2

This commit is contained in:
Zuul
2026-02-12 16:38:48 +00:00
committed by Gerrit Code Review
3 changed files with 12 additions and 10 deletions

View File

@@ -0,0 +1,9 @@
---
fixes:
- |
Fixes a bug in the zone migration strategy where audits would fail due to
an unhandled exception when trying to plan instance migration that exist
in Nova but not in Watcher's compute model.
The strategy now filters out the elements that are not found in the model,
allowing the audit to complete successfully. For more details, please see
`Bug #2098984 <https://bugs.launchpad.net/watcher/+bug/2098984>`_.

View File

@@ -540,7 +540,7 @@ class ZoneMigration(base.ZoneMigrationBaseStrategy):
return [i for i in self.nova.get_instance_list()
if getattr(i, 'OS-EXT-SRV-ATTR:host') in src_node_list and
self.compute_model.get_instance_by_uuid(i.id)]
self.compute_model.has_node(i.id)]
def get_volumes(self):
"""Get migrate target volumes

View File

@@ -17,7 +17,6 @@ from unittest import mock
import cinderclient
import novaclient
from watcher.common import exception as watcher_exception
from watcher.common import utils
from watcher.decision_engine.strategy import strategies
from watcher.tests.decision_engine.model import faker_cluster_state
@@ -168,15 +167,9 @@ class TestZoneMigration(TestBaseStrategy):
# Mock nova helper to return our test instance
self.m_n_helper.get_instance_list.return_value = [instance_on_src1]
# FIXME(dviroel): Fix this test together with bug #2098984
# It should return an empty list and not raise an exception
# Verify that the instance does not exist in the model
# instances = self.strategy.get_instances()
# self.assertEqual([], instances)
self.assertRaises(
watcher_exception.InstanceNotFound,
self.strategy.get_instances)
instances = self.strategy.get_instances()
self.assertEqual([], instances)
def test_get_volumes_with_volume_not_found(self):
# Create a test volume without an known id