summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitry Tantsur <dtantsur@protonmail.com>2022-06-23 19:24:44 +0200
committerDmitry Tantsur <dtantsur@protonmail.com>2022-07-04 12:08:46 +0000
commit28796c3da7b8a39f1b25e81919db280d7f6569c4 (patch)
treed728dc9e5aa1abbc59a4b55864c99ef69bb8f9aa
parent00242e4a07b22abb143da05ef32bf01853596957 (diff)
downloadironic-28796c3da7b8a39f1b25e81919db280d7f6569c4.tar.gz
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 (cherry picked from commit 65583e64172a0188d125117d1f2288e105832395)
-rw-r--r--ironic/common/pxe_utils.py16
-rw-r--r--ironic/conductor/utils.py8
-rw-r--r--ironic/drivers/modules/deploy_utils.py14
-rw-r--r--ironic/drivers/modules/redfish/boot.py7
-rw-r--r--ironic/tests/unit/common/test_pxe_utils.py13
-rw-r--r--ironic/tests/unit/drivers/modules/redfish/test_boot.py10
-rw-r--r--releasenotes/notes/redfish-ramdisk-no-agent-490b5edb0b2387e5.yaml6
7 files changed, 60 insertions, 14 deletions
diff --git a/ironic/common/pxe_utils.py b/ironic/common/pxe_utils.py
index 5e112ee30..b0f1d906f 100644
--- a/ironic/common/pxe_utils.py
+++ b/ironic/common/pxe_utils.py
@@ -229,10 +229,13 @@ def get_kernel_ramdisk_info(node_uuid, driver_info, mode='deploy',
image_info = {}
labels = KERNEL_RAMDISK_LABELS[mode]
for label in labels:
- image_info[label] = (
- str(driver_info[label]),
- os.path.join(root_dir, node_uuid, label)
- )
+ try:
+ image_info[label] = (
+ str(driver_info[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
@@ -619,6 +622,11 @@ def parse_driver_info(node, mode='deploy'):
:returns: A dict with the driver_info values.
: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
params_to_check = KERNEL_RAMDISK_LABELS[mode]
diff --git a/ironic/conductor/utils.py b/ironic/conductor/utils.py
index b418d9d0a..aeb067a7a 100644
--- a/ironic/conductor/utils.py
+++ b/ironic/conductor/utils.py
@@ -938,7 +938,7 @@ def notify_conductor_resume_deploy(task):
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.
:param node: the node to consider
@@ -948,9 +948,9 @@ def skip_automated_cleaning(node):
elif node.automated_clean is None:
return not CONF.conductor.automated_clean
else:
- LOG.info("Automated cleaning is disabled via the API for "
- "node %(node)s",
- {'node': node.uuid})
+ if log:
+ LOG.info("Automated cleaning is disabled via the API for "
+ "node %(node)s", {'node': node.uuid})
return True
diff --git a/ironic/drivers/modules/deploy_utils.py b/ironic/drivers/modules/deploy_utils.py
index f6883249f..89258b134 100644
--- a/ironic/drivers/modules/deploy_utils.py
+++ b/ironic/drivers/modules/deploy_utils.py
@@ -1452,3 +1452,17 @@ def get_root_device_for_deploy(node):
_('Failed to validate the root device hints %(hints)s (from the '
'node\'s %(source)s) for node %(node)s: %(error)s') %
{'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)
diff --git a/ironic/drivers/modules/redfish/boot.py b/ironic/drivers/modules/redfish/boot.py
index 55c826fc6..ea776850c 100644
--- a/ironic/drivers/modules/redfish/boot.py
+++ b/ironic/drivers/modules/redfish/boot.py
@@ -96,9 +96,14 @@ def _parse_driver_info(node):
:raises: InvalidParameterValue, if any of the parameters have invalid
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
- mode = deploy_utils.rescue_or_deploy_mode(node)
iso_param = f'{mode}_iso'
iso_ref = driver_utils.get_agent_iso(node, deprecated_prefix='redfish',
mode=mode)
diff --git a/ironic/tests/unit/common/test_pxe_utils.py b/ironic/tests/unit/common/test_pxe_utils.py
index 5ba0033a7..6ebc677d9 100644
--- a/ironic/tests/unit/common/test_pxe_utils.py
+++ b/ironic/tests/unit/common/test_pxe_utils.py
@@ -921,11 +921,7 @@ class TestPXEUtils(db_base.DbTestCase):
def test_get_kernel_ramdisk_info_bad_driver_info(self):
self.config(tftp_root='/tftp', group='pxe')
node_uuid = 'fake-node'
- driver_info = {}
- self.assertRaises(KeyError,
- pxe_utils.get_kernel_ramdisk_info,
- node_uuid,
- driver_info)
+ self.assertEqual({}, pxe_utils.get_kernel_ramdisk_info(node_uuid, {}))
def test_get_rescue_kr_info(self):
expected_dir = '/tftp'
@@ -1189,6 +1185,13 @@ class PXEInterfacesTestCase(db_base.DbTestCase):
group='conductor')
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):
expected_info = {'deploy_ramdisk':
(DRV_INFO_DICT['deploy_ramdisk'],
diff --git a/ironic/tests/unit/drivers/modules/redfish/test_boot.py b/ironic/tests/unit/drivers/modules/redfish/test_boot.py
index e69c29dca..799370394 100644
--- a/ironic/tests/unit/drivers/modules/redfish/test_boot.py
+++ b/ironic/tests/unit/drivers/modules/redfish/test_boot.py
@@ -58,6 +58,16 @@ class RedfishVirtualMediaBootTestCase(db_base.DbTestCase):
'Unable to import the sushy library',
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):
with task_manager.acquire(self.context, self.node.uuid,
shared=True) as task:
diff --git a/releasenotes/notes/redfish-ramdisk-no-agent-490b5edb0b2387e5.yaml b/releasenotes/notes/redfish-ramdisk-no-agent-490b5edb0b2387e5.yaml
new file mode 100644
index 000000000..cbb49c447
--- /dev/null
+++ b/releasenotes/notes/redfish-ramdisk-no-agent-490b5edb0b2387e5.yaml
@@ -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.