From 57f55190ff4a6e0df06ae2affba5b4f633ef7c48 Mon Sep 17 00:00:00 2001 From: suzhengwei Date: Mon, 22 Jun 2020 09:26:46 +0000 Subject: [PATCH] Revert "Don't revert Migrate action" Whether to revert migrate action when the action_plan fails is determained by 'rollback_actionplan' option. This reverts commit c522e881b1ba02f4b97d9de9d58fabd4ce884249. Change-Id: I5379018b7838dff4caf0ee0ce06cfa32e7b37b12 --- watcher/applier/actions/migration.py | 2 +- .../tests/applier/actions/test_migration.py | 23 +++++++++++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/watcher/applier/actions/migration.py b/watcher/applier/actions/migration.py index 4a6bc2683..781f378cd 100644 --- a/watcher/applier/actions/migration.py +++ b/watcher/applier/actions/migration.py @@ -186,7 +186,7 @@ class Migrate(base.BaseAction): return self.migrate(destination=self.destination_node) def revert(self): - LOG.info('Migrate action do not revert!') + return self.migrate(destination=self.source_node) def abort(self): nova = nova_helper.NovaHelper(osc=self.osc) diff --git a/watcher/tests/applier/actions/test_migration.py b/watcher/tests/applier/actions/test_migration.py index c0a951df0..d7078320b 100644 --- a/watcher/tests/applier/actions/test_migration.py +++ b/watcher/tests/applier/actions/test_migration.py @@ -187,6 +187,29 @@ class TestMigration(base.TestCase): dest_hostname="compute2-hostname" ) + def test_revert_live_migration(self): + self.m_helper.find_instance.return_value = self.INSTANCE_UUID + + self.action.revert() + + self.m_helper_cls.assert_called_once_with(osc=self.m_osc) + self.m_helper.live_migrate_instance.assert_called_once_with( + instance_id=self.INSTANCE_UUID, + dest_hostname="compute1-hostname" + ) + + def test_revert_cold_migration(self): + self.m_helper.find_instance.return_value = self.INSTANCE_UUID + + self.action_cold.revert() + + self.m_helper_cls.assert_called_once_with(osc=self.m_osc) + self.m_helper.watcher_non_live_migrate_instance.\ + assert_called_once_with( + instance_id=self.INSTANCE_UUID, + dest_hostname="compute1-hostname" + ) + def test_abort_live_migrate(self): migration = mock.MagicMock() migration.id = "2"