Browse Source

Merge "Fix regression in ramdisk deploy kernel parameters"

changes/43/802643/1
Zuul 2 months ago
committed by Gerrit Code Review
parent
commit
652a161f9a
  1. 10
      ironic/drivers/modules/image_utils.py
  2. 77
      ironic/tests/unit/drivers/modules/test_image_utils.py
  3. 5
      releasenotes/notes/custom-params-cleaning-f938549964ff6df0.yaml

10
ironic/drivers/modules/image_utils.py

@ -29,6 +29,7 @@ from ironic.common import exception
from ironic.common.glance_service import service_utils
from ironic.common.i18n import _
from ironic.common import images
from ironic.common import states
from ironic.common import swift
from ironic.common import utils
from ironic.conf import CONF
@ -426,9 +427,12 @@ def _prepare_iso_image(task, kernel_href, ramdisk_href,
{'node': task.node.uuid})
i_info = task.node.instance_info
is_ramdisk_boot = (
task.node.provision_state == states.DEPLOYING
and deploy_utils.get_boot_option(task.node) == 'ramdisk'
)
boot_option = deploy_utils.get_boot_option(task.node)
if boot_option == 'ramdisk':
if is_ramdisk_boot:
download_source = (i_info.get('ramdisk_image_download_source')
or CONF.deploy.ramdisk_image_download_source)
else:
@ -463,7 +467,7 @@ def _prepare_iso_image(task, kernel_href, ramdisk_href,
# NOTE(TheJulia): Until we support modifying a base iso, most of
# this logic actually does nothing in the end. But it should!
if boot_option == "ramdisk":
if is_ramdisk_boot:
if not base_iso:
kernel_params = "root=/dev/ram0 text "
kernel_params += i_info.get("ramdisk_kernel_arguments", "")

77
ironic/tests/unit/drivers/modules/test_image_utils.py

@ -22,6 +22,7 @@ from oslo_utils import importutils
from oslo_utils import uuidutils
from ironic.common import images
from ironic.common import states
from ironic.common import utils
from ironic.conductor import task_manager
from ironic.drivers.modules import deploy_utils
@ -241,7 +242,8 @@ class RedfishImageUtilsTestCase(db_base.DbTestCase):
enabled_inspect_interfaces=['redfish'],
enabled_bios_interfaces=['redfish'])
self.node = obj_utils.create_test_node(
self.context, driver='redfish', driver_info=INFO_DICT)
self.context, driver='redfish', driver_info=INFO_DICT,
provision_state=states.DEPLOYING)
@mock.patch.object(image_utils.ImageHandler, 'unpublish_image',
autospec=True)
@ -579,6 +581,79 @@ class RedfishImageUtilsTestCase(db_base.DbTestCase):
root_uuid='1be26c0b-03f2-4d2e-ae87-c02d7f33c123',
base_iso='/path/to/baseiso', inject_files=None)
@mock.patch.object(deploy_utils, 'get_boot_option', lambda node: 'ramdisk')
@mock.patch.object(image_utils.ImageHandler, 'publish_image',
autospec=True)
@mock.patch.object(images, 'create_boot_iso', autospec=True)
def test__prepare_iso_image_kernel_params_for_ramdisk(
self, mock_create_boot_iso, mock_publish_image):
with task_manager.acquire(self.context, self.node.uuid,
shared=True) as task:
kernel_params = 'network-config=base64-cloudinit-blob'
task.node.instance_info['ramdisk_kernel_arguments'] = kernel_params
image_utils._prepare_iso_image(
task, 'http://kernel/img', 'http://ramdisk/img',
bootloader_href=None, root_uuid=task.node.uuid)
mock_create_boot_iso.assert_called_once_with(
mock.ANY, mock.ANY, 'http://kernel/img', 'http://ramdisk/img',
boot_mode='bios', esp_image_href=None,
kernel_params="root=/dev/ram0 text " + kernel_params,
root_uuid='1be26c0b-03f2-4d2e-ae87-c02d7f33c123',
base_iso=None, inject_files=None)
@mock.patch.object(deploy_utils, 'get_boot_option', lambda node: 'ramdisk')
@mock.patch.object(image_utils.ImageHandler, 'publish_image',
autospec=True)
@mock.patch.object(images, 'create_boot_iso', autospec=True)
def test__prepare_iso_image_kernel_params_for_ramdisk_boot_iso(
self, mock_create_boot_iso, mock_publish_image):
with task_manager.acquire(self.context, self.node.uuid,
shared=True) as task:
kernel_params = 'network-config=base64-cloudinit-blob'
task.node.instance_info['ramdisk_kernel_arguments'] = kernel_params
image_utils._prepare_iso_image(
task, 'http://kernel/img', 'http://ramdisk/img',
bootloader_href=None, root_uuid=task.node.uuid,
base_iso='/path/to/baseiso')
mock_create_boot_iso.assert_called_once_with(
mock.ANY, mock.ANY, 'http://kernel/img', 'http://ramdisk/img',
boot_mode='bios', esp_image_href=None,
# No custom parameters with a boot ISO present
kernel_params=None,
root_uuid='1be26c0b-03f2-4d2e-ae87-c02d7f33c123',
base_iso='/path/to/baseiso', inject_files=None)
@mock.patch.object(deploy_utils, 'get_boot_option', lambda node: 'ramdisk')
@mock.patch.object(image_utils.ImageHandler, 'publish_image',
autospec=True)
@mock.patch.object(images, 'create_boot_iso', autospec=True)
def test__prepare_iso_image_kernel_params_for_ramdisk_cleaning(
self, mock_create_boot_iso, mock_publish_image):
with task_manager.acquire(self.context, self.node.uuid,
shared=True) as task:
kernel_params = 'network-config=base64-cloudinit-blob'
task.node.driver_info['kernel_append_params'] = kernel_params
task.node.provision_state = states.CLEANING
image_utils._prepare_iso_image(
task, 'http://kernel/img', 'http://ramdisk/img',
bootloader_href=None, root_uuid=task.node.uuid,
base_iso='/path/to/baseiso')
mock_create_boot_iso.assert_called_once_with(
mock.ANY, mock.ANY, 'http://kernel/img', 'http://ramdisk/img',
boot_mode='bios', esp_image_href=None,
kernel_params=kernel_params,
root_uuid='1be26c0b-03f2-4d2e-ae87-c02d7f33c123',
base_iso='/path/to/baseiso', inject_files=None)
@mock.patch.object(image_utils.ImageHandler, 'publish_image',
autospec=True)
@mock.patch.object(images, 'create_boot_iso', autospec=True)

5
releasenotes/notes/custom-params-cleaning-f938549964ff6df0.yaml

@ -0,0 +1,5 @@
---
fixes:
- |
Fixes a regression in the ``ramdisk`` deploy where custom kernel parameters
were not used during inspection and cleaning.
Loading…
Cancel
Save