No deploy_kernel/ramdisk with the ramdisk deploy and no cleaning

Ramdisk deploys don't use IPA, no need to provide it. Cleaning may need
the agent, so only skip verification if cleaning is disabled.

Other boot interfaces may need fixing as well, I haven't checked them.

Change-Id: Ia2739311f065e19ba539fe3df7268075d6075787
This commit is contained in:
Dmitry Tantsur 2022-06-23 19:24:44 +02:00
parent 1b6114934c
commit 65583e6417
7 changed files with 60 additions and 14 deletions

View File

@ -229,10 +229,13 @@ def get_kernel_ramdisk_info(node_uuid, driver_info, mode='deploy',
image_info = {} image_info = {}
labels = KERNEL_RAMDISK_LABELS[mode] labels = KERNEL_RAMDISK_LABELS[mode]
for label in labels: for label in labels:
try:
image_info[label] = ( image_info[label] = (
str(driver_info[label]), str(driver_info[label]),
os.path.join(root_dir, node_uuid, label) os.path.join(root_dir, node_uuid, label)
) )
except KeyError:
pass # may be absent in rare cases, verified in parse_driver_info
return image_info return image_info
@ -619,6 +622,11 @@ def parse_driver_info(node, mode='deploy'):
:returns: A dict with the driver_info values. :returns: A dict with the driver_info values.
:raises: MissingParameterValue :raises: MissingParameterValue
""" """
if not deploy_utils.needs_agent_ramdisk(node, mode=mode):
# Ramdisk deploy does not need an agent, nor does it support any other,
# options. Skipping.
return {}
info = node.driver_info info = node.driver_info
params_to_check = KERNEL_RAMDISK_LABELS[mode] params_to_check = KERNEL_RAMDISK_LABELS[mode]

View File

@ -938,7 +938,7 @@ def notify_conductor_resume_deploy(task):
notify_conductor_resume_operation(task, 'deploy') notify_conductor_resume_operation(task, 'deploy')
def skip_automated_cleaning(node): def skip_automated_cleaning(node, log=True):
"""Checks if node cleaning needs to be skipped for an specific node. """Checks if node cleaning needs to be skipped for an specific node.
:param node: the node to consider :param node: the node to consider
@ -948,9 +948,9 @@ def skip_automated_cleaning(node):
elif node.automated_clean is None: elif node.automated_clean is None:
return not CONF.conductor.automated_clean return not CONF.conductor.automated_clean
else: else:
if log:
LOG.info("Automated cleaning is disabled via the API for " LOG.info("Automated cleaning is disabled via the API for "
"node %(node)s", "node %(node)s", {'node': node.uuid})
{'node': node.uuid})
return True return True

View File

@ -1452,3 +1452,17 @@ def get_root_device_for_deploy(node):
_('Failed to validate the root device hints %(hints)s (from the ' _('Failed to validate the root device hints %(hints)s (from the '
'node\'s %(source)s) for node %(node)s: %(error)s') % 'node\'s %(source)s) for node %(node)s: %(error)s') %
{'node': node.uuid, 'hints': hints, 'source': source, 'error': e}) {'node': node.uuid, 'hints': hints, 'source': source, 'error': e})
def needs_agent_ramdisk(node, mode='deploy'):
"""Checks whether the node requires an agent ramdisk now."""
if mode != 'deploy':
return True # Rescue always needs a ramdisk
if get_boot_option(node) != 'ramdisk':
return True # Normal deploys need an agent
# Ramdisk deploys don't need an agent, but cleaning will. Since we don't
# want nodes to be stuck on deletion, require an agent when cleaning is
# enabled.
return not manager_utils.skip_automated_cleaning(node, log=False)

View File

@ -91,9 +91,14 @@ def _parse_driver_info(node):
:raises: InvalidParameterValue, if any of the parameters have invalid :raises: InvalidParameterValue, if any of the parameters have invalid
value. value.
""" """
mode = deploy_utils.rescue_or_deploy_mode(node)
if not deploy_utils.needs_agent_ramdisk(node, mode=mode):
# Ramdisk deploy does not need an agent, nor does it support any other
# options. Skipping.
return {'can_provide_config': False}
d_info = node.driver_info d_info = node.driver_info
mode = deploy_utils.rescue_or_deploy_mode(node)
iso_param = f'{mode}_iso' iso_param = f'{mode}_iso'
iso_ref = driver_utils.get_agent_iso(node, deprecated_prefix='redfish', iso_ref = driver_utils.get_agent_iso(node, deprecated_prefix='redfish',
mode=mode) mode=mode)

View File

@ -921,11 +921,7 @@ class TestPXEUtils(db_base.DbTestCase):
def test_get_kernel_ramdisk_info_bad_driver_info(self): def test_get_kernel_ramdisk_info_bad_driver_info(self):
self.config(tftp_root='/tftp', group='pxe') self.config(tftp_root='/tftp', group='pxe')
node_uuid = 'fake-node' node_uuid = 'fake-node'
driver_info = {} self.assertEqual({}, pxe_utils.get_kernel_ramdisk_info(node_uuid, {}))
self.assertRaises(KeyError,
pxe_utils.get_kernel_ramdisk_info,
node_uuid,
driver_info)
def test_get_rescue_kr_info(self): def test_get_rescue_kr_info(self):
expected_dir = '/tftp' expected_dir = '/tftp'
@ -1189,6 +1185,13 @@ class PXEInterfacesTestCase(db_base.DbTestCase):
group='conductor') group='conductor')
self._test_parse_driver_info_missing_ramdisk(mode='rescue') self._test_parse_driver_info_missing_ramdisk(mode='rescue')
@mock.patch.object(deploy_utils, 'get_boot_option', lambda node: 'ramdisk')
def test_parse_driver_info_ramdisk(self):
self.node.driver_info = {}
self.node.automated_clean = False
image_info = pxe_utils.parse_driver_info(self.node, mode='deploy')
self.assertEqual({}, image_info)
def test__get_deploy_image_info(self): def test__get_deploy_image_info(self):
expected_info = {'deploy_ramdisk': expected_info = {'deploy_ramdisk':
(DRV_INFO_DICT['deploy_ramdisk'], (DRV_INFO_DICT['deploy_ramdisk'],

View File

@ -58,6 +58,16 @@ class RedfishVirtualMediaBootTestCase(db_base.DbTestCase):
'Unable to import the sushy library', 'Unable to import the sushy library',
redfish_boot.RedfishVirtualMediaBoot) redfish_boot.RedfishVirtualMediaBoot)
@mock.patch.object(deploy_utils, 'get_boot_option', lambda node: 'ramdisk')
def test_parse_driver_info_ramdisk(self):
with task_manager.acquire(self.context, self.node.uuid,
shared=True) as task:
task.node.driver_info = {}
task.node.automated_clean = False
actual_driver_info = redfish_boot._parse_driver_info(task.node)
self.assertEqual({'can_provide_config': False},
actual_driver_info)
def test_parse_driver_info_deploy(self): def test_parse_driver_info_deploy(self):
with task_manager.acquire(self.context, self.node.uuid, with task_manager.acquire(self.context, self.node.uuid,
shared=True) as task: shared=True) as task:

View File

@ -0,0 +1,6 @@
---
fixes:
- |
When the ``ramdisk`` deploy interface is used and automated cleaning is
disabled, the ``pxe``, ``ipxe`` and ``redfish-virtual-media`` boot
interfaces no longer require a deploy kernel/ramdisk to be provided.