Remove a pause before cleaning when fast-tracking

When fast track mode is used, ironic still waits for the next heartbeat
before running the first clean step, because prepare_cleaning
unconditionally returns CLEANWAIT for agent drivers. This patch fixes
it by returning None for fast-track.

Agent code then needs to refresh clean steps before proceeding,
otherwise it will assume an empty steps list.

Change-Id: I86225b3e34c63a0124a2a63f8a624dd00a8d38e4
This commit is contained in:
Dmitry Tantsur 2021-04-12 15:29:50 +02:00
parent 65e2e19098
commit ff7a32bc7f
5 changed files with 35 additions and 7 deletions

View File

@ -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):

View File

@ -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):

View File

@ -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):

View File

@ -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[

View File

@ -0,0 +1,5 @@
---
fixes:
- |
Removes unnecessary delay before the start of the cleaning process when
fast-track is used.