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:
parent
65e2e19098
commit
ff7a32bc7f
ironic
drivers/modules
tests/unit/drivers/modules
releasenotes/notes
@ -716,6 +716,13 @@ class AgentBaseMixin(object):
|
|||||||
"""Whether agent boot is managed by ironic."""
|
"""Whether agent boot is managed by ironic."""
|
||||||
return True
|
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')
|
@METRICS.timer('AgentBaseMixin.tear_down')
|
||||||
@task_manager.require_exclusive_lock
|
@task_manager.require_exclusive_lock
|
||||||
def tear_down(self, task):
|
def tear_down(self, task):
|
||||||
@ -776,8 +783,12 @@ class AgentBaseMixin(object):
|
|||||||
has an invalid value.
|
has an invalid value.
|
||||||
:returns: states.CLEANWAIT to signify an asynchronous prepare
|
: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))
|
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')
|
@METRICS.timer('AgentDeployMixin.tear_down_cleaning')
|
||||||
def tear_down_cleaning(self, task):
|
def tear_down_cleaning(self, task):
|
||||||
|
@ -691,9 +691,8 @@ def prepare_inband_cleaning(task, manage_boot=True):
|
|||||||
fast_track = manager_utils.is_fast_track(task)
|
fast_track = manager_utils.is_fast_track(task)
|
||||||
if not fast_track:
|
if not fast_track:
|
||||||
manager_utils.node_power_action(task, states.REBOOT)
|
manager_utils.node_power_action(task, states.REBOOT)
|
||||||
|
# Tell the conductor we are waiting for the agent to boot.
|
||||||
# Tell the conductor we are waiting for the agent to boot.
|
return states.CLEANWAIT
|
||||||
return states.CLEANWAIT
|
|
||||||
|
|
||||||
|
|
||||||
def tear_down_inband_cleaning(task, manage_boot=True):
|
def tear_down_inband_cleaning(task, manage_boot=True):
|
||||||
|
@ -1203,6 +1203,18 @@ class TestAgentDeploy(db_base.DbTestCase):
|
|||||||
prepare_inband_cleaning_mock.assert_called_once_with(
|
prepare_inband_cleaning_mock.assert_called_once_with(
|
||||||
task, manage_boot=False)
|
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',
|
@mock.patch.object(deploy_utils, 'tear_down_inband_cleaning',
|
||||||
autospec=True)
|
autospec=True)
|
||||||
def test_tear_down_cleaning(self, tear_down_cleaning_mock):
|
def test_tear_down_cleaning(self, tear_down_cleaning_mock):
|
||||||
|
@ -1148,15 +1148,16 @@ class AgentMethodsTestCase(db_base.DbTestCase):
|
|||||||
is_fast_track_mock.return_value = fast_track
|
is_fast_track_mock.return_value = fast_track
|
||||||
with task_manager.acquire(
|
with task_manager.acquire(
|
||||||
self.context, self.node.uuid, shared=False) as task:
|
self.context, self.node.uuid, shared=False) as task:
|
||||||
self.assertEqual(
|
result = utils.prepare_inband_cleaning(task,
|
||||||
states.CLEANWAIT,
|
manage_boot=manage_boot)
|
||||||
utils.prepare_inband_cleaning(task, manage_boot=manage_boot))
|
|
||||||
add_cleaning_network_mock.assert_called_once_with(
|
add_cleaning_network_mock.assert_called_once_with(
|
||||||
task.driver.network, task)
|
task.driver.network, task)
|
||||||
if not fast_track:
|
if not fast_track:
|
||||||
|
self.assertEqual(states.CLEANWAIT, result)
|
||||||
power_mock.assert_called_once_with(task, states.REBOOT)
|
power_mock.assert_called_once_with(task, states.REBOOT)
|
||||||
else:
|
else:
|
||||||
self.assertFalse(power_mock.called)
|
self.assertFalse(power_mock.called)
|
||||||
|
self.assertIsNone(result)
|
||||||
self.assertEqual(1, task.node.driver_internal_info[
|
self.assertEqual(1, task.node.driver_internal_info[
|
||||||
'agent_erase_devices_iterations'])
|
'agent_erase_devices_iterations'])
|
||||||
self.assertIs(True, task.node.driver_internal_info[
|
self.assertIs(True, task.node.driver_internal_info[
|
||||||
|
5
releasenotes/notes/fast-track-opt-d50eab2cc58fddcb.yaml
Normal file
5
releasenotes/notes/fast-track-opt-d50eab2cc58fddcb.yaml
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
fixes:
|
||||||
|
- |
|
||||||
|
Removes unnecessary delay before the start of the cleaning process when
|
||||||
|
fast-track is used.
|
Loading…
Reference in New Issue
Block a user