summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ironic/drivers/modules/agent_base.py13
-rw-r--r--ironic/drivers/modules/deploy_utils.py5
-rw-r--r--ironic/tests/unit/drivers/modules/test_agent.py12
-rw-r--r--ironic/tests/unit/drivers/modules/test_deploy_utils.py7
-rw-r--r--releasenotes/notes/fast-track-opt-d50eab2cc58fddcb.yaml5
5 files changed, 35 insertions, 7 deletions
diff --git a/ironic/drivers/modules/agent_base.py b/ironic/drivers/modules/agent_base.py
index c51f8ec81..2bc059899 100644
--- a/ironic/drivers/modules/agent_base.py
+++ b/ironic/drivers/modules/agent_base.py
@@ -716,6 +716,13 @@ class AgentBaseMixin(object):
"""Whether agent boot is managed by ironic."""
return True
+ def refresh_steps(self, task, step_type):
+ """Refresh the node's cached steps.
+
+ :param task: a TaskManager instance
+ :param step_type: "clean" or "deploy"
+ """
+
@METRICS.timer('AgentBaseMixin.tear_down')
@task_manager.require_exclusive_lock
def tear_down(self, task):
@@ -776,8 +783,12 @@ class AgentBaseMixin(object):
has an invalid value.
:returns: states.CLEANWAIT to signify an asynchronous prepare
"""
- return deploy_utils.prepare_inband_cleaning(
+ result = deploy_utils.prepare_inband_cleaning(
task, manage_boot=self.should_manage_boot(task))
+ if result is None:
+ # Fast-track, ensure the steps are available.
+ self.refresh_steps(task, 'clean')
+ return result
@METRICS.timer('AgentDeployMixin.tear_down_cleaning')
def tear_down_cleaning(self, task):
diff --git a/ironic/drivers/modules/deploy_utils.py b/ironic/drivers/modules/deploy_utils.py
index e3b7fa3fb..3575a7732 100644
--- a/ironic/drivers/modules/deploy_utils.py
+++ b/ironic/drivers/modules/deploy_utils.py
@@ -691,9 +691,8 @@ def prepare_inband_cleaning(task, manage_boot=True):
fast_track = manager_utils.is_fast_track(task)
if not fast_track:
manager_utils.node_power_action(task, states.REBOOT)
-
- # Tell the conductor we are waiting for the agent to boot.
- return states.CLEANWAIT
+ # Tell the conductor we are waiting for the agent to boot.
+ return states.CLEANWAIT
def tear_down_inband_cleaning(task, manage_boot=True):
diff --git a/ironic/tests/unit/drivers/modules/test_agent.py b/ironic/tests/unit/drivers/modules/test_agent.py
index ef3d77476..77a5f30b4 100644
--- a/ironic/tests/unit/drivers/modules/test_agent.py
+++ b/ironic/tests/unit/drivers/modules/test_agent.py
@@ -1203,6 +1203,18 @@ class TestAgentDeploy(db_base.DbTestCase):
prepare_inband_cleaning_mock.assert_called_once_with(
task, manage_boot=False)
+ @mock.patch.object(agent.AgentDeploy, 'refresh_steps', autospec=True)
+ @mock.patch.object(deploy_utils, 'prepare_inband_cleaning', autospec=True)
+ def test_prepare_cleaning_fast_track(self, prepare_inband_cleaning_mock,
+ refresh_steps_mock):
+ prepare_inband_cleaning_mock.return_value = None
+ with task_manager.acquire(self.context, self.node.uuid) as task:
+ self.assertIsNone(self.driver.prepare_cleaning(task))
+ prepare_inband_cleaning_mock.assert_called_once_with(
+ task, manage_boot=True)
+ refresh_steps_mock.assert_called_once_with(
+ self.driver, task, 'clean')
+
@mock.patch.object(deploy_utils, 'tear_down_inband_cleaning',
autospec=True)
def test_tear_down_cleaning(self, tear_down_cleaning_mock):
diff --git a/ironic/tests/unit/drivers/modules/test_deploy_utils.py b/ironic/tests/unit/drivers/modules/test_deploy_utils.py
index 748ee8420..c168b367c 100644
--- a/ironic/tests/unit/drivers/modules/test_deploy_utils.py
+++ b/ironic/tests/unit/drivers/modules/test_deploy_utils.py
@@ -1148,15 +1148,16 @@ class AgentMethodsTestCase(db_base.DbTestCase):
is_fast_track_mock.return_value = fast_track
with task_manager.acquire(
self.context, self.node.uuid, shared=False) as task:
- self.assertEqual(
- states.CLEANWAIT,
- utils.prepare_inband_cleaning(task, manage_boot=manage_boot))
+ result = utils.prepare_inband_cleaning(task,
+ manage_boot=manage_boot)
add_cleaning_network_mock.assert_called_once_with(
task.driver.network, task)
if not fast_track:
+ self.assertEqual(states.CLEANWAIT, result)
power_mock.assert_called_once_with(task, states.REBOOT)
else:
self.assertFalse(power_mock.called)
+ self.assertIsNone(result)
self.assertEqual(1, task.node.driver_internal_info[
'agent_erase_devices_iterations'])
self.assertIs(True, task.node.driver_internal_info[
diff --git a/releasenotes/notes/fast-track-opt-d50eab2cc58fddcb.yaml b/releasenotes/notes/fast-track-opt-d50eab2cc58fddcb.yaml
new file mode 100644
index 000000000..b9658dd1c
--- /dev/null
+++ b/releasenotes/notes/fast-track-opt-d50eab2cc58fddcb.yaml
@@ -0,0 +1,5 @@
+---
+fixes:
+ - |
+ Removes unnecessary delay before the start of the cleaning process when
+ fast-track is used.