From 8f2e487b2bd9168822268fcca1ab43ff93084afe Mon Sep 17 00:00:00 2001 From: Hironori Shiina Date: Fri, 16 Feb 2018 10:03:19 +0900 Subject: [PATCH] Set 'initrd' to 'rescue_ramdisk' for rescue with iPXE The kernel paramter 'initrd' is hard-coded as 'deploy_ramdisk' in iPXE config template. A rescue ramdisk may fail to boot due to this wrong paramter. This patch sets this 'initrd' paramter properly to 'deploy_ramdisk' or 'rescue_ramdisk' by adding a new pxe option. Change-Id: I8ad1223dc289bbe915ee4ca8db66c8f80bf08f15 Closes-Bug: 1749860 --- ironic/drivers/modules/ipxe_config.template | 2 +- ironic/drivers/modules/pxe.py | 2 ++ ironic/tests/unit/common/test_pxe_utils.py | 2 ++ ironic/tests/unit/drivers/modules/test_pxe.py | 2 ++ releasenotes/notes/bug-1749860-457292cf62e18a0e.yaml | 6 ++++++ 5 files changed, 13 insertions(+), 1 deletion(-) create mode 100644 releasenotes/notes/bug-1749860-457292cf62e18a0e.yaml diff --git a/ironic/drivers/modules/ipxe_config.template b/ironic/drivers/modules/ipxe_config.template index 5b6be48a2a..5fba7215ee 100644 --- a/ironic/drivers/modules/ipxe_config.template +++ b/ironic/drivers/modules/ipxe_config.template @@ -4,7 +4,7 @@ goto deploy :deploy imgfree -kernel {% if pxe_options.ipxe_timeout > 0 %}--timeout {{ pxe_options.ipxe_timeout }} {% endif %}{{ pxe_options.deployment_aki_path }} selinux=0 troubleshoot=0 text {{ pxe_options.pxe_append_params|default("", true) }} ip=${ip}:${next-server}:${gateway}:${netmask} BOOTIF=${mac} ipa-api-url={{ pxe_options['ipa-api-url'] }} initrd=deploy_ramdisk coreos.configdrive=0 || goto deploy +kernel {% if pxe_options.ipxe_timeout > 0 %}--timeout {{ pxe_options.ipxe_timeout }} {% endif %}{{ pxe_options.deployment_aki_path }} selinux=0 troubleshoot=0 text {{ pxe_options.pxe_append_params|default("", true) }} ip=${ip}:${next-server}:${gateway}:${netmask} BOOTIF=${mac} ipa-api-url={{ pxe_options['ipa-api-url'] }} initrd={{ pxe_options.initrd_filename|default("deploy_ramdisk", true) }} coreos.configdrive=0 || goto deploy initrd {% if pxe_options.ipxe_timeout > 0 %}--timeout {{ pxe_options.ipxe_timeout }} {% endif %}{{ pxe_options.deployment_ari_path }} || goto deploy boot diff --git a/ironic/drivers/modules/pxe.py b/ironic/drivers/modules/pxe.py index 493d5e29b7..8ce679a4f0 100644 --- a/ironic/drivers/modules/pxe.py +++ b/ironic/drivers/modules/pxe.py @@ -178,6 +178,8 @@ def _build_deploy_pxe_options(task, pxe_info, mode='deploy'): else: pxe_opts[option] = pxe_utils.get_path_relative_to_tftp_root( pxe_info[label][1]) + if CONF.pxe.ipxe_enabled: + pxe_opts['initrd_filename'] = ramdisk_label return pxe_opts diff --git a/ironic/tests/unit/common/test_pxe_utils.py b/ironic/tests/unit/common/test_pxe_utils.py index 9b16addc05..6761a3388f 100644 --- a/ironic/tests/unit/common/test_pxe_utils.py +++ b/ironic/tests/unit/common/test_pxe_utils.py @@ -57,6 +57,7 @@ class TestPXEUtils(db_base.DbTestCase): 'deployment_ari_path': 'http://1.2.3.4:1234/deploy_ramdisk', 'aki_path': 'http://1.2.3.4:1234/kernel', 'ari_path': 'http://1.2.3.4:1234/ramdisk', + 'initrd_filename': 'deploy_ramdisk', }) self.ipxe_options_timeout = self.ipxe_options.copy() @@ -73,6 +74,7 @@ class TestPXEUtils(db_base.DbTestCase): 'username': 'fake_username', 'password': 'fake_password' }) + self.ipxe_options_boot_from_volume.pop('initrd_filename', None) self.node = object_utils.create_test_node(self.context) diff --git a/ironic/tests/unit/drivers/modules/test_pxe.py b/ironic/tests/unit/drivers/modules/test_pxe.py index fffe3d368f..fe0f364cc0 100644 --- a/ironic/tests/unit/drivers/modules/test_pxe.py +++ b/ironic/tests/unit/drivers/modules/test_pxe.py @@ -415,6 +415,7 @@ class PXEPrivateMethodsTestCase(db_base.DbTestCase): 'ipxe_timeout': ipxe_timeout_in_ms, 'ari_path': ramdisk, 'aki_path': kernel, + 'initrd_filename': ramdisk_label, } if mode == 'rescue': @@ -431,6 +432,7 @@ class PXEPrivateMethodsTestCase(db_base.DbTestCase): 'password': 'fake_password'}) expected_options.pop('deployment_aki_path') expected_options.pop('deployment_ari_path') + expected_options.pop('initrd_filename') with task_manager.acquire(self.context, self.node.uuid, shared=True) as task: diff --git a/releasenotes/notes/bug-1749860-457292cf62e18a0e.yaml b/releasenotes/notes/bug-1749860-457292cf62e18a0e.yaml new file mode 100644 index 0000000000..b053d153ee --- /dev/null +++ b/releasenotes/notes/bug-1749860-457292cf62e18a0e.yaml @@ -0,0 +1,6 @@ +--- +fixes: + - | + Fixes rescue timeout due to incorrect kernel parameter in the iPXE script. + See `bug 1749860 `_ for + details.