diff options
author | Dmitry Tantsur <dtantsur@protonmail.com> | 2022-02-10 18:11:15 +0100 |
---|---|---|
committer | Dmitry Tantsur <dtantsur@protonmail.com> | 2022-02-15 12:59:34 +0000 |
commit | 5e2919b280bb1ab3bc3f0f00555830e25b4faa68 (patch) | |
tree | 2eee7f6b8a8c5b3e85391994a94b6f01b4e604a1 | |
parent | 8a0b6384af815ae14f74f2851690e9cfffb46414 (diff) | |
download | ironic-5e2919b280bb1ab3bc3f0f00555830e25b4faa68.tar.gz |
Set correct initrd_filename for iPXE when using Swift
iPXE derives its "file names" from the last component of the URL path.
In case of the conductor's local server it's {mode}_{component} where
mode = deploy/rescue and component = kernel/ramdisk. However, in case
of Swift/Ceph, the last component will be different. This patch accounts
for it.
Change-Id: I7ba5545032069509a9c302abe1c21537ccb5ec8a
(cherry picked from commit c975eaa8c67d917feac75c9053cddcfb708e08a3)
-rw-r--r-- | ironic/common/pxe_utils.py | 8 | ||||
-rw-r--r-- | ironic/tests/unit/common/test_pxe_utils.py | 11 | ||||
-rw-r--r-- | releasenotes/notes/initrd_filename-ac68e96f1c9fb576.yaml | 6 |
3 files changed, 20 insertions, 5 deletions
diff --git a/ironic/common/pxe_utils.py b/ironic/common/pxe_utils.py index 08d6d3f98..8ef1bfb47 100644 --- a/ironic/common/pxe_utils.py +++ b/ironic/common/pxe_utils.py @@ -18,6 +18,7 @@ import copy import os import shutil import tempfile +from urllib import parse as urlparse from ironic_lib import utils as ironic_utils import jinja2 @@ -770,6 +771,7 @@ def build_deploy_pxe_options(task, pxe_info, mode='deploy', node = task.node kernel_label = '%s_kernel' % mode ramdisk_label = '%s_ramdisk' % mode + initrd_filename = ramdisk_label for label, option in ((kernel_label, 'deployment_aki_path'), (ramdisk_label, 'deployment_ari_path')): if ipxe_enabled: @@ -778,6 +780,10 @@ def build_deploy_pxe_options(task, pxe_info, mode='deploy', and service_utils.is_glance_image(image_href)): pxe_opts[option] = images.get_temp_url_for_glance_image( task.context, image_href) + if label == ramdisk_label: + path = urlparse.urlparse(pxe_opts[option]).path.strip('/') + if path: + initrd_filename = path.split('/')[-1] else: pxe_opts[option] = '/'.join([CONF.deploy.http_url, node.uuid, label]) @@ -785,7 +791,7 @@ def build_deploy_pxe_options(task, pxe_info, mode='deploy', pxe_opts[option] = get_path_relative_to_tftp_root( pxe_info[label][1]) if ipxe_enabled: - pxe_opts['initrd_filename'] = ramdisk_label + pxe_opts['initrd_filename'] = initrd_filename return pxe_opts diff --git a/ironic/tests/unit/common/test_pxe_utils.py b/ironic/tests/unit/common/test_pxe_utils.py index 822c5f4ff..85afdd6b8 100644 --- a/ironic/tests/unit/common/test_pxe_utils.py +++ b/ironic/tests/unit/common/test_pxe_utils.py @@ -1791,9 +1791,10 @@ class iPXEBuildConfigOptionsTestCase(db_base.DbTestCase): self.config(ipxe_use_swift=True, group='pxe') glance = mock.Mock() glance_mock.return_value = glance - glance.swift_temp_url.side_effect = [ - pxe_kernel, pxe_ramdisk] = [ - 'swift_kernel', 'swift_ramdisk'] + glance.swift_temp_url.side_effect = [pxe_kernel, pxe_ramdisk] = [ + 'http://example.com/account/swift_kernel', + 'http://example.com/account/swift_ramdisk' + ] image_info = { kernel_label: (uuidutils.generate_uuid(), os.path.join(root_dir, @@ -1804,6 +1805,7 @@ class iPXEBuildConfigOptionsTestCase(db_base.DbTestCase): self.node.uuid, ramdisk_label)) } + expected_initrd_filename = 'swift_ramdisk' else: pxe_kernel = os.path.join(http_url, self.node.uuid, kernel_label) @@ -1819,6 +1821,7 @@ class iPXEBuildConfigOptionsTestCase(db_base.DbTestCase): self.node.uuid, ramdisk_label)) } + expected_initrd_filename = ramdisk_label kernel = os.path.join(http_url, self.node.uuid, 'kernel') ramdisk = os.path.join(http_url, self.node.uuid, 'ramdisk') @@ -1853,7 +1856,7 @@ class iPXEBuildConfigOptionsTestCase(db_base.DbTestCase): 'ipxe_timeout': ipxe_timeout_in_ms, 'ari_path': ramdisk, 'aki_path': kernel, - 'initrd_filename': ramdisk_label, + 'initrd_filename': expected_initrd_filename, } if mode == 'rescue': diff --git a/releasenotes/notes/initrd_filename-ac68e96f1c9fb576.yaml b/releasenotes/notes/initrd_filename-ac68e96f1c9fb576.yaml new file mode 100644 index 000000000..b9eea262e --- /dev/null +++ b/releasenotes/notes/initrd_filename-ac68e96f1c9fb576.yaml @@ -0,0 +1,6 @@ +--- +fixes: + - | + Fixes the ``initrd`` kernel parameter when booting ramdisk directly from + Swift/RadosGW using iPXE. Previously it was always ``deploy_ramdisk``, + even when the actual file name is different. |