diff options
-rw-r--r-- | ironic/drivers/modules/deploy_utils.py | 3 | ||||
-rw-r--r-- | ironic/tests/unit/drivers/modules/test_deploy_utils.py | 31 | ||||
-rw-r--r-- | releasenotes/notes/vmedia-fast-track-903076c33c4aca04.yaml | 9 |
3 files changed, 43 insertions, 0 deletions
diff --git a/ironic/drivers/modules/deploy_utils.py b/ironic/drivers/modules/deploy_utils.py index f75c97cf5..ae576c608 100644 --- a/ironic/drivers/modules/deploy_utils.py +++ b/ironic/drivers/modules/deploy_utils.py @@ -649,6 +649,9 @@ def prepare_inband_cleaning(task, manage_boot=True): ramdisk_opts = build_agent_options(task.node) task.driver.boot.prepare_ramdisk(task, ramdisk_opts) + # NOTE(dtantsur): calling prepare_ramdisk may power off the node, so we + # need to check fast-track again and reboot if needed. + fast_track = manager_utils.is_fast_track(task) if not fast_track: manager_utils.node_power_action(task, states.REBOOT) diff --git a/ironic/tests/unit/drivers/modules/test_deploy_utils.py b/ironic/tests/unit/drivers/modules/test_deploy_utils.py index 0a582dee7..f0b0e9621 100644 --- a/ironic/tests/unit/drivers/modules/test_deploy_utils.py +++ b/ironic/tests/unit/drivers/modules/test_deploy_utils.py @@ -1191,6 +1191,37 @@ class AgentMethodsTestCase(db_base.DbTestCase): def test_prepare_inband_cleaning_fast_track(self): self._test_prepare_inband_cleaning(fast_track=True) + @mock.patch('ironic.conductor.utils.power_on_node_if_needed', + autospec=True) + @mock.patch('ironic.conductor.utils.is_fast_track', autospec=True) + @mock.patch.object(pxe.PXEBoot, 'prepare_ramdisk', autospec=True) + @mock.patch('ironic.conductor.utils.node_power_action', autospec=True) + @mock.patch.object(utils, 'build_agent_options', autospec=True) + @mock.patch('ironic.drivers.modules.network.flat.FlatNetwork.' + 'add_cleaning_network', autospec=True) + def test_prepare_inband_cleaning_broken_fast_track( + self, add_cleaning_network_mock, + build_options_mock, power_mock, prepare_ramdisk_mock, + is_fast_track_mock, power_on_if_needed_mock): + build_options_mock.return_value = {'a': 'b'} + is_fast_track_mock.side_effect = [True, False] + with task_manager.acquire( + self.context, self.node.uuid, shared=False) as task: + self.assertEqual( + states.CLEANWAIT, + utils.prepare_inband_cleaning(task)) + add_cleaning_network_mock.assert_called_once_with( + task.driver.network, task) + power_mock.assert_called_once_with(task, states.REBOOT) + self.assertEqual(1, task.node.driver_internal_info[ + 'agent_erase_devices_iterations']) + self.assertIs(True, task.node.driver_internal_info[ + 'agent_erase_devices_zeroize']) + prepare_ramdisk_mock.assert_called_once_with( + mock.ANY, mock.ANY, {'a': 'b'}) + build_options_mock.assert_called_once_with(task.node) + self.assertFalse(power_on_if_needed_mock.called) + @mock.patch('ironic.conductor.utils.is_fast_track', autospec=True) @mock.patch.object(pxe.PXEBoot, 'clean_up_ramdisk', autospec=True) @mock.patch('ironic.drivers.modules.network.flat.FlatNetwork.' diff --git a/releasenotes/notes/vmedia-fast-track-903076c33c4aca04.yaml b/releasenotes/notes/vmedia-fast-track-903076c33c4aca04.yaml new file mode 100644 index 000000000..34cf448e0 --- /dev/null +++ b/releasenotes/notes/vmedia-fast-track-903076c33c4aca04.yaml @@ -0,0 +1,9 @@ +--- +issues: + - | + When ``redfish-virtual-media`` is used, fast-track mode will not work as + expected, nodes will be rebooted between operations. +fixes: + - | + Fixes timeout in fast-track mode with ``redfish-virtual-media`` when + running one operation after another (e.g. cleaning after inspection). |