Fix take over of ACTIVE nodes in AgentDeploy

currently if the ACTIVE netboot-ed node with driver based on AgentDeploy
is being taken over by another conductor due to the whole host with
previous conductor died/went offline, the node will not be fully
operational as it cannot be rebooted from inside:

- its DHCP options are still pointing to the TFTP/HTTP servers of old
  (now offline) conductor host
- new conductor host does not have the user image kernel and ramdisk
  cached
- new conductor host lacks PXE env prepared for such node.

Fix this by actually calling out to `driver.boot.prepare_instance`
in AgentDeploy.prepare for ACTIVE nodes.

Change-Id: Ie21e285e22c6a8b168f8c9776a125f3bb71fead7
Closes-Bug: #1646038
This commit is contained in:
Pavlo Shchelokovskyy committed 2017-01-10 18:57:47 +02:00
1 parent 035ad6a60b
commit 79010d6033
3 files changed
+10 -5

No files matched your search

+3 -4
View File
@@ -420,16 +420,15 @@ class AgentDeploy(AgentDeployMixin, base.DeployInterface):
Glance href and is not HTTP(S) URL.
:raises: any boot interface's prepare_ramdisk exceptions.
"""
# Nodes deployed by AgentDeploy always boot from disk now. So there
# is nothing to be done in prepare() when it's called during
# take over.
node = task.node
if node.provision_state == states.DEPLOYING:
# Adding the node to provisioning network so that the dhcp
# options get added for the provisioning port.
manager_utils.node_power_action(task, states.POWER_OFF)
task.driver.network.add_provisioning_network(task)
if node.provision_state not in [states.ACTIVE, states.ADOPTING]:
if node.provision_state == states.ACTIVE:
task.driver.boot.prepare_instance(task)
elif node.provision_state != states.ADOPTING:
node.instance_info = deploy_utils.build_instance_info_for_deploy(
task)
node.save()
@@ -328,12 +328,14 @@ class TestAgentDeploy(db_base.DbTestCase):
@mock.patch('ironic.drivers.modules.network.flat.FlatNetwork.'
'add_provisioning_network', autospec=True)
@mock.patch.object(pxe.PXEBoot, 'prepare_instance')
@mock.patch.object(pxe.PXEBoot, 'prepare_ramdisk')
@mock.patch.object(deploy_utils, 'build_agent_options')
@mock.patch.object(deploy_utils, 'build_instance_info_for_deploy')
def test_prepare_active(
self, build_instance_info_mock, build_options_mock,
pxe_prepare_ramdisk_mock, add_provisioning_net_mock):
pxe_prepare_ramdisk_mock, pxe_prepare_instance_mock,
add_provisioning_net_mock):
with task_manager.acquire(
self.context, self.node['uuid'], shared=False) as task:
task.node.provision_state = states.ACTIVE
@@ -343,6 +345,7 @@ class TestAgentDeploy(db_base.DbTestCase):
self.assertFalse(build_instance_info_mock.called)
self.assertFalse(build_options_mock.called)
self.assertFalse(pxe_prepare_ramdisk_mock.called)
self.assertTrue(pxe_prepare_instance_mock.called)
self.assertFalse(add_provisioning_net_mock.called)
@mock.patch('ironic.drivers.modules.network.flat.FlatNetwork.'
@@ -0,0 +1,3 @@
---
fixes:
- AgentDeploy now correctly supports take-over for ACTIVE netboot-ed nodes.