From 78f54dfefa6e184c8e77f0c42682e6b3a02199fe Mon Sep 17 00:00:00 2001 From: Przemyslaw Szczerbik Date: Fri, 24 May 2024 02:23:28 -0700 Subject: [PATCH] Build PXE config for node in SERVICING state When [pxe]enable_netboot_fallback option is enabled, it's necessary to build PXE config for nodes in SERVICING provisioning state. Otherwise node servicing tear down will fail and node will be placed into servicing failed state. Closes-Bug: #2069413 Change-Id: Ib00504563f9fa7bed99a0fa1949ac99ea6870875 Signed-off-by: Przemyslaw Szczerbik --- ironic/common/pxe_utils.py | 3 ++- ironic/tests/unit/common/test_pxe_utils.py | 21 +++++++++++++++++++ .../notes/bug-2069413-fc9262c573f2fe10.yaml | 7 +++++++ 3 files changed, 30 insertions(+), 1 deletion(-) create mode 100644 releasenotes/notes/bug-2069413-fc9262c573f2fe10.yaml diff --git a/ironic/common/pxe_utils.py b/ironic/common/pxe_utils.py index 3f8eca953e..c496076488 100644 --- a/ironic/common/pxe_utils.py +++ b/ironic/common/pxe_utils.py @@ -1014,7 +1014,8 @@ def build_service_pxe_config(task, instance_image_info, # fail if the agent was booted outside the direct actions of the # boot interface. if (node.provision_state in [states.ACTIVE, states.UNRESCUING, - states.DEPLOYING, states.ADOPTING] + states.DEPLOYING, states.ADOPTING, + states.SERVICING] and not os.path.isfile(pxe_config_path)): pxe_options = build_pxe_config_options(task, instance_image_info, service=True, diff --git a/ironic/tests/unit/common/test_pxe_utils.py b/ironic/tests/unit/common/test_pxe_utils.py index 27d08ecf55..55661cd6d4 100644 --- a/ironic/tests/unit/common/test_pxe_utils.py +++ b/ironic/tests/unit/common/test_pxe_utils.py @@ -2598,6 +2598,27 @@ class iPXEBuildServicePXEConfigTestCase(db_base.DbTestCase): mock_pxe_utils.assert_called() mock_switch.assert_called() + @mock.patch.object(pxe_utils, 'create_pxe_config', autospec=True) + @mock.patch.object(deploy_utils, 'switch_pxe_config', autospec=True) + def test_build_service_pxe_config_servicing(self, mock_switch, + mock_pxe_utils): + self.node.provision_state = states.SERVICING + + driver_internal_info = self.node.driver_internal_info + driver_internal_info['is_whole_disk_image'] = True + self.node.driver_internal_info = driver_internal_info + self.node.save() + + image_info = {} + + with task_manager.acquire(self.context, self.node.uuid, + shared=True) as task: + pxe_utils.build_service_pxe_config(task, image_info, 'id', + is_whole_disk_image=True) + + mock_pxe_utils.assert_called() + mock_switch.assert_called() + @mock.patch.object(ironic_utils, 'unlink_without_raise', autospec=True) @mock.patch.object(pxe_utils, 'clean_up_pxe_config', autospec=True) diff --git a/releasenotes/notes/bug-2069413-fc9262c573f2fe10.yaml b/releasenotes/notes/bug-2069413-fc9262c573f2fe10.yaml new file mode 100644 index 0000000000..6a97ada43a --- /dev/null +++ b/releasenotes/notes/bug-2069413-fc9262c573f2fe10.yaml @@ -0,0 +1,7 @@ +--- +fixes: + - | + [`bug 2069413 `_] + Fixes an issue with node servicing that caused node to be put into + 'service failed' state when Ironic configuration option + [pxe]enable_netboot_fallback was enabled.