summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitry Tantsur <dtantsur@protonmail.com>2020-10-30 16:41:01 +0100
committerDmitry Tantsur <dtantsur@protonmail.com>2020-11-02 14:20:29 +0000
commit8abf572886b9410e0de54a6c69273d29c307c9ea (patch)
treecd7d1ced39c47972f5b6bc0ec2ff5fe3c719296f
parent0e30d9ab313b117a658bf902eb2f6f84cd08c0f3 (diff)
downloadironic-8abf572886b9410e0de54a6c69273d29c307c9ea.tar.gz
Prevent timeouts when using fast-track with redfish-virtual-media
Calling prepare_ramdisk may break fast-track, as it's the case with redfish-virtual-media (it powers nodes off unconditionally). To avoid timeouts, check fast-track status again after prepare_ramdisk. Change-Id: Iad2d6f4827bd7e8b2a02005fe18d31ec8d37db97 (cherry picked from commit 551ca9c8f7556b162afe28d1b1ba020a06251555)
-rw-r--r--ironic/drivers/modules/deploy_utils.py3
-rw-r--r--ironic/tests/unit/drivers/modules/test_deploy_utils.py31
-rw-r--r--releasenotes/notes/vmedia-fast-track-903076c33c4aca04.yaml9
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).