diff options
author | Dmitry Tantsur <dtantsur@protonmail.com> | 2022-02-10 18:11:15 +0100 |
---|---|---|
committer | Dmitry Tantsur <dtantsur@protonmail.com> | 2022-02-10 18:51:30 +0100 |
commit | c975eaa8c67d917feac75c9053cddcfb708e08a3 (patch) | |
tree | 9ab9bf75813e7f6c239ae16f3039b40c18900bb1 | |
parent | a4a89d6b20a03e692e0550e3a34a97c7a63f266c (diff) | |
download | ironic-c975eaa8c67d917feac75c9053cddcfb708e08a3.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
-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 e87f73185..39d0cc9df 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 @@ -744,6 +745,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: @@ -752,6 +754,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]) @@ -759,7 +765,7 @@ def build_deploy_pxe_options(task, pxe_info, mode='deploy', pxe_opts[option] = os.path.relpath(pxe_info[label][1], CONF.pxe.tftp_root) 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 3c4307615..52372f395 100644 --- a/ironic/tests/unit/common/test_pxe_utils.py +++ b/ironic/tests/unit/common/test_pxe_utils.py @@ -1916,9 +1916,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, @@ -1929,6 +1930,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) @@ -1944,6 +1946,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') @@ -1978,7 +1981,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. |