Browse Source

Fix fast-track with the direct deploy interface

Several small fixes:

1) Make sure the deploy.deploy step returns DEPLOYWAIT after running
   prepare_image otherwise the conductor wrongly assumes that the
   deploy is done.
2) Handle the case when provision_state==DEPLOYWAIT when returning
   from an asynchronous deploy step.
3) Do not assume that prepare_image is always the last command to run,
   sometimes get_deploy_steps sneaks in.
4) Do not issue a deprecation warning when receiving "agent is busy"
   on get_deploy_steps, this is normal for fast-track.

   NOTE: the last change is missing from stable/train

Conflicts:
	ironic/conductor/deployments.py
	ironic/drivers/modules/agent_base.py
	ironic/tests/unit/conductor/test_deployments.py
	ironic/tests/unit/drivers/modules/test_agent_base_vendor.py

Change-Id: I19274c48bd36fca19961a7d78467ec8c29f85905
(cherry picked from commit f0803493de)
changes/92/737692/1
Dmitry Tantsur 2 weeks ago
parent
commit
089b84e4cd
4 changed files with 36 additions and 12 deletions
  1. +2
    -1
      ironic/conductor/manager.py
  2. +7
    -10
      ironic/drivers/modules/agent.py
  3. +22
    -1
      ironic/tests/unit/drivers/modules/test_agent.py
  4. +5
    -0
      releasenotes/notes/direct-fast-track-d0f43850b6e80751.yaml

+ 2
- 1
ironic/conductor/manager.py View File

@@ -3985,7 +3985,8 @@ def _do_next_deploy_step(task, step_index, conductor_id):
LOG.info('Deploy step %(step)s on node %(node)s being '
'executed asynchronously, waiting for driver.',
{'node': node.uuid, 'step': step})
task.process_event('wait')
if task.node.provision_state != states.DEPLOYWAIT:
task.process_event('wait')
return
elif result is not None:
# NOTE(rloo): This is an internal/dev error; shouldn't happen.


+ 7
- 10
ironic/drivers/modules/agent.py View File

@@ -184,17 +184,13 @@ class AgentDeployMixin(agent_base_vendor.AgentDeployMixin):
if not commands:
return False

last_command = commands[-1]

if last_command['command_name'] != 'prepare_image':
# catches race condition where prepare_image is still processing
# so deploy hasn't started yet
try:
last_command = next(cmd for cmd in reversed(commands)
if cmd['command_name'] == 'prepare_image')
except StopIteration:
return False

if last_command['command_status'] != 'RUNNING':
return True

return False
else:
return last_command['command_status'] != 'RUNNING'

@METRICS.timer('AgentDeployMixin.continue_deploy')
@task_manager.require_exclusive_lock
@@ -462,6 +458,7 @@ class AgentDeploy(AgentDeployMixin, base.DeployInterface):
# the state machine state going from DEPLOYWAIT -> DEPLOYING
task.process_event('wait')
self.continue_deploy(task)
return states.DEPLOYWAIT
elif task.driver.storage.should_write_image(task):
# Check if the driver has already performed a reboot in a previous
# deploy step.


+ 22
- 1
ironic/tests/unit/drivers/modules/test_agent.py View File

@@ -377,7 +377,7 @@ class TestAgentDeploy(db_base.DbTestCase):
self.node.save()
with task_manager.acquire(
self.context, self.node['uuid'], shared=False) as task:
self.driver.deploy(task)
self.assertEqual(states.DEPLOYWAIT, self.driver.deploy(task))
self.assertFalse(power_mock.called)
self.assertFalse(mock_pxe_instance.called)
task.node.refresh()
@@ -1529,6 +1529,27 @@ class TestAgentDeploy(db_base.DbTestCase):
'command_status': 'RUNNING'}]
self.assertFalse(task.driver.deploy.deploy_is_done(task))

@mock.patch.object(agent_client.AgentClient, 'get_commands_status',
autospec=True)
def test_deploy_is_done_several_results(self, mock_get_cmd):
with task_manager.acquire(self.context, self.node.uuid) as task:
mock_get_cmd.return_value = [
{'command_name': 'prepare_image', 'command_status': 'SUCCESS'},
{'command_name': 'other_command', 'command_status': 'SUCCESS'},
{'command_name': 'prepare_image', 'command_status': 'RUNNING'},
]
self.assertFalse(task.driver.deploy.deploy_is_done(task))

@mock.patch.object(agent_client.AgentClient, 'get_commands_status',
autospec=True)
def test_deploy_is_done_not_the_last(self, mock_get_cmd):
with task_manager.acquire(self.context, self.node.uuid) as task:
mock_get_cmd.return_value = [
{'command_name': 'prepare_image', 'command_status': 'SUCCESS'},
{'command_name': 'other_command', 'command_status': 'SUCCESS'},
]
self.assertTrue(task.driver.deploy.deploy_is_done(task))

@mock.patch.object(manager_utils, 'restore_power_state_if_needed',
autospec=True)
@mock.patch.object(manager_utils, 'power_on_node_if_needed',


+ 5
- 0
releasenotes/notes/direct-fast-track-d0f43850b6e80751.yaml View File

@@ -0,0 +1,5 @@
---
fixes:
- |
Fixes fast-track deployments with the ``direct`` deploy interface that
used to hang previously.

Loading…
Cancel
Save