From e9ecdbbadc6a5e2a0936830251ecd1d560bf017e Mon Sep 17 00:00:00 2001 From: Shivanand Tendulker Date: Thu, 31 Aug 2017 00:25:56 -0400 Subject: [PATCH] Boot from volume fails with 'iscsi' deploy interface When boot from volume is requested for a node with 'iscsi' deploy interface and no 'image_source' is provided in 'node.instance_info'. It calls boot.prepare_ramdisk() and fails while trying to perform validation for 'image_source'. This commit fixes the issue. Closes-Bug: #1714147 Change-Id: Ia3bad7f3325576ba091284f9b63b67a1b26cb3b7 --- ironic/drivers/modules/iscsi_deploy.py | 5 +++++ ironic/tests/unit/drivers/modules/test_iscsi_deploy.py | 7 +++---- ...ot-from-volume-for-iscsi-deploy-71c1f2905498c50d.yaml | 9 +++++++++ 3 files changed, 17 insertions(+), 4 deletions(-) create mode 100644 releasenotes/notes/fix-boot-from-volume-for-iscsi-deploy-71c1f2905498c50d.yaml diff --git a/ironic/drivers/modules/iscsi_deploy.py b/ironic/drivers/modules/iscsi_deploy.py index cba4a0bd1d..e4a6e07b9c 100644 --- a/ironic/drivers/modules/iscsi_deploy.py +++ b/ironic/drivers/modules/iscsi_deploy.py @@ -528,6 +528,11 @@ class ISCSIDeploy(AgentDeployMixin, base.DeployInterface): task.driver.network.unconfigure_tenant_networks(task) task.driver.network.add_provisioning_network(task) task.driver.storage.attach_volumes(task) + if not task.driver.storage.should_write_image(task): + # We have nothing else to do as this is handled in the + # backend storage system, and we can return to the caller + # as we do not need to boot the agent to deploy. + return deploy_opts = deploy_utils.build_agent_options(node) task.driver.boot.prepare_ramdisk(task, deploy_opts) diff --git a/ironic/tests/unit/drivers/modules/test_iscsi_deploy.py b/ironic/tests/unit/drivers/modules/test_iscsi_deploy.py index b0a179b5a0..7745b972a8 100644 --- a/ironic/tests/unit/drivers/modules/test_iscsi_deploy.py +++ b/ironic/tests/unit/drivers/modules/test_iscsi_deploy.py @@ -681,15 +681,14 @@ class ISCSIDeployTestCase(db_base.DbTestCase): task.driver.deploy.prepare(task) - mock_agent_options.assert_called_once_with(task.node) - mock_prepare_ramdisk.assert_called_once_with( - task.driver.boot, task, {'c': 'd'}) + self.assertFalse(mock_agent_options.called) + self.assertFalse(mock_prepare_ramdisk.called) self.assertFalse(add_provisioning_net_mock.called) self.assertFalse(unconfigure_tenant_net_mock.called) storage_driver_info_mock.assert_called_once_with(task) storage_attach_volumes_mock.assert_called_once_with( task.driver.storage, task) - self.assertEqual(1, storage_should_write_mock.call_count) + self.assertEqual(2, storage_should_write_mock.call_count) @mock.patch.object(manager_utils, 'node_power_action', autospec=True) @mock.patch.object(iscsi_deploy, 'check_image_size', autospec=True) diff --git a/releasenotes/notes/fix-boot-from-volume-for-iscsi-deploy-71c1f2905498c50d.yaml b/releasenotes/notes/fix-boot-from-volume-for-iscsi-deploy-71c1f2905498c50d.yaml new file mode 100644 index 0000000000..f41958340d --- /dev/null +++ b/releasenotes/notes/fix-boot-from-volume-for-iscsi-deploy-71c1f2905498c50d.yaml @@ -0,0 +1,9 @@ +--- +fixes: + - | + Fixes an issue in boot from volume for ``iscsi`` deploy interface. Boot + from a volume fails when it is requested for a node having ``iscsi`` + deploy interface and no ``image_source`` is provided in node's + ``node.instance_info``. It fails while trying to perform validation of + ``image_source``. See `bug 1714147 + `_ for details.