diff --git a/ironic/drivers/modules/ipxe.py b/ironic/drivers/modules/ipxe.py index 49ac313481..e60cb1c872 100644 --- a/ironic/drivers/modules/ipxe.py +++ b/ironic/drivers/modules/ipxe.py @@ -43,6 +43,8 @@ COMMON_PROPERTIES = pxe_base.COMMON_PROPERTIES class iPXEBoot(pxe_base.PXEBaseMixin, base.BootInterface): + ipxe_enabled = True + capabilities = ['iscsi_volume_boot', 'ramdisk_boot', 'ipxe_boot'] def __init__(self): @@ -303,4 +305,4 @@ class iPXEBoot(pxe_base.PXEBaseMixin, base.BootInterface): 'to clean up images for node %(node)s: %(err)s', {'node': node.uuid, 'err': e}) else: - pxe_utils.clean_up_pxe_env(task, images_info) + pxe_utils.clean_up_pxe_env(task, images_info, ipxe_enabled=True) diff --git a/ironic/drivers/modules/pxe_base.py b/ironic/drivers/modules/pxe_base.py index dfc4a0e4a3..3f0bb0d193 100644 --- a/ironic/drivers/modules/pxe_base.py +++ b/ironic/drivers/modules/pxe_base.py @@ -67,6 +67,8 @@ COMMON_PROPERTIES.update(RESCUE_PROPERTIES) class PXEBaseMixin(object): + ipxe_enabled = False + def get_properties(self): """Return the properties of the interface. @@ -93,13 +95,15 @@ class PXEBaseMixin(object): node = task.node mode = deploy_utils.rescue_or_deploy_mode(node) try: - images_info = pxe_utils.get_image_info(node, mode=mode) + images_info = pxe_utils.get_image_info( + node, mode=mode, ipxe_enabled=self.ipxe_enabled) except exception.MissingParameterValue as e: LOG.warning('Could not get %(mode)s image info ' 'to clean up images for node %(node)s: %(err)s', {'mode': mode, 'node': node.uuid, 'err': e}) else: - pxe_utils.clean_up_pxe_env(task, images_info) + pxe_utils.clean_up_pxe_env( + task, images_info, ipxe_enabled=self.ipxe_enabled) @METRICS.timer('PXEBaseMixin.validate_rescue') def validate_rescue(self, task): diff --git a/ironic/tests/unit/drivers/modules/test_ipxe.py b/ironic/tests/unit/drivers/modules/test_ipxe.py index 65f0194cdb..5bc639efff 100644 --- a/ironic/tests/unit/drivers/modules/test_ipxe.py +++ b/ironic/tests/unit/drivers/modules/test_ipxe.py @@ -589,8 +589,10 @@ class iPXEBootTestCase(db_base.DbTestCase): ramdisk_label: ['', '/path/to/' + ramdisk_label]} get_image_info_mock.return_value = image_info task.driver.boot.clean_up_ramdisk(task) - clean_up_pxe_env_mock.assert_called_once_with(task, image_info) - get_image_info_mock.assert_called_once_with(task.node, mode=mode) + clean_up_pxe_env_mock.assert_called_once_with( + task, image_info, ipxe_enabled=True) + get_image_info_mock.assert_called_once_with( + task.node, mode=mode, ipxe_enabled=True) def test_clean_up_ramdisk(self): self.node.provision_state = states.DEPLOYING @@ -834,7 +836,8 @@ class iPXEBootTestCase(db_base.DbTestCase): 'ramdisk': ['', '/path/to/ramdisk']} get_image_info_mock.return_value = image_info task.driver.boot.clean_up_instance(task) - clean_up_pxe_env_mock.assert_called_once_with(task, image_info) + clean_up_pxe_env_mock.assert_called_once_with( + task, image_info, ipxe_enabled=True) get_image_info_mock.assert_called_once_with( task, ipxe_enabled=True) diff --git a/ironic/tests/unit/drivers/modules/test_iscsi_deploy.py b/ironic/tests/unit/drivers/modules/test_iscsi_deploy.py index e36431b543..36192ea3ed 100644 --- a/ironic/tests/unit/drivers/modules/test_iscsi_deploy.py +++ b/ironic/tests/unit/drivers/modules/test_iscsi_deploy.py @@ -1266,8 +1266,8 @@ class CleanUpFullFlowTestCase(db_base.DbTestCase): shared=True) as task: task.driver.deploy.clean_up(task) mock_get_instance_image_info.assert_called_with(task) - mock_get_deploy_image_info.assert_called_with(task.node, - mode='deploy') + mock_get_deploy_image_info.assert_called_with( + task.node, mode='deploy', ipxe_enabled=False) set_dhcp_provider_mock.assert_called_once_with() clean_dhcp_mock.assert_called_once_with(task) for path in ([self.kernel_path, self.image_path, self.config_path] diff --git a/ironic/tests/unit/drivers/modules/test_pxe.py b/ironic/tests/unit/drivers/modules/test_pxe.py index 8d710b4d0e..300be541f4 100644 --- a/ironic/tests/unit/drivers/modules/test_pxe.py +++ b/ironic/tests/unit/drivers/modules/test_pxe.py @@ -591,8 +591,10 @@ class PXEBootTestCase(db_base.DbTestCase): ramdisk_label: ['', '/path/to/' + ramdisk_label]} get_image_info_mock.return_value = image_info task.driver.boot.clean_up_ramdisk(task) - clean_up_pxe_env_mock.assert_called_once_with(task, image_info) - get_image_info_mock.assert_called_once_with(task.node, mode=mode) + clean_up_pxe_env_mock.assert_called_once_with( + task, image_info, ipxe_enabled=False) + get_image_info_mock.assert_called_once_with( + task.node, mode=mode, ipxe_enabled=False) def test_clean_up_ramdisk(self): self.node.provision_state = states.DEPLOYING diff --git a/releasenotes/notes/cleanup-ipxe-f1349e2ac9ec2825.yaml b/releasenotes/notes/cleanup-ipxe-f1349e2ac9ec2825.yaml new file mode 100644 index 0000000000..5fbb35ac4e --- /dev/null +++ b/releasenotes/notes/cleanup-ipxe-f1349e2ac9ec2825.yaml @@ -0,0 +1,5 @@ +--- +fixes: + - | + Now passing proper flags during clean up of iPXE boot environments, + so that no leftovers are left after node tear down.