From 01345082661b4f34275bdd6feeea6d73972c50be Mon Sep 17 00:00:00 2001 From: Julia Kreger Date: Mon, 27 Jul 2020 12:25:22 -0700 Subject: [PATCH] Prevents power sync with ADOPTFAIL nodes We shouldn't attempt to sync the power state on nodes in the adopt failed state as they may be in some sort of intermediate state indicitive of their adoption failure. Change-Id: I779155ba2dc3f256273a7f45c5354ee8e6a6fabf Story: 2007901 Task: 40296 --- ironic/conductor/manager.py | 3 ++- ironic/tests/unit/conductor/test_manager.py | 22 +++++++++++++++++++ ...r-sync-for-adoptfail-d2498f1a2e997ed7.yaml | 5 +++++ 3 files changed, 29 insertions(+), 1 deletion(-) create mode 100644 releasenotes/notes/skip-power-sync-for-adoptfail-d2498f1a2e997ed7.yaml diff --git a/ironic/conductor/manager.py b/ironic/conductor/manager.py index 80dd6eb7b0..abfbbaf93d 100644 --- a/ironic/conductor/manager.py +++ b/ironic/conductor/manager.py @@ -81,7 +81,8 @@ LOG = log.getLogger(__name__) METRICS = metrics_utils.get_metrics_logger(__name__) -SYNC_EXCLUDED_STATES = (states.DEPLOYWAIT, states.CLEANWAIT, states.ENROLL) +SYNC_EXCLUDED_STATES = (states.DEPLOYWAIT, states.CLEANWAIT, states.ENROLL, + states.ADOPTFAIL) class ConductorManager(base_manager.BaseConductorManager): diff --git a/ironic/tests/unit/conductor/test_manager.py b/ironic/tests/unit/conductor/test_manager.py index 1946eab309..77b2c4e562 100644 --- a/ironic/tests/unit/conductor/test_manager.py +++ b/ironic/tests/unit/conductor/test_manager.py @@ -5227,6 +5227,28 @@ class ManagerSyncPowerStatesTestCase(mgr_utils.CommonMixIn, shared=True) sync_mock.assert_called_once_with(task, mock.ANY) + def test_single_node_adopt_failed(self, get_nodeinfo_mock, + mapped_mock, acquire_mock, sync_mock): + get_nodeinfo_mock.return_value = self._get_nodeinfo_list_response() + mapped_mock.return_value = True + task = self._create_task( + node_attrs=dict(uuid=self.node.uuid, + provision_state=states.ADOPTFAIL)) + acquire_mock.side_effect = self._get_acquire_side_effect(task) + + self.service._sync_power_states(self.context) + + get_nodeinfo_mock.assert_called_once_with( + columns=self.columns, filters=self.filters) + mapped_mock.assert_called_once_with(self.service, + self.node.uuid, + self.node.driver, + self.node.conductor_group) + acquire_mock.assert_called_once_with(self.context, self.node.uuid, + purpose=mock.ANY, + shared=True) + sync_mock.assert_not_called() + def test__sync_power_state_multiple_nodes(self, get_nodeinfo_mock, mapped_mock, acquire_mock, sync_mock): diff --git a/releasenotes/notes/skip-power-sync-for-adoptfail-d2498f1a2e997ed7.yaml b/releasenotes/notes/skip-power-sync-for-adoptfail-d2498f1a2e997ed7.yaml new file mode 100644 index 0000000000..2bff91797d --- /dev/null +++ b/releasenotes/notes/skip-power-sync-for-adoptfail-d2498f1a2e997ed7.yaml @@ -0,0 +1,5 @@ +--- +fixes: + - | + Fixes the conductor so the power sync operations are not asserted for + nodes in the ``adopt failed`` state.