summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitry Tantsur <dtantsur@protonmail.com>2022-06-23 19:24:44 +0200
committerRiccardo Pittau <elfosardo@gmail.com>2022-07-11 13:33:12 +0000
commit2752c73b3d15f47dfd9c42068169bc762b132d85 (patch)
tree31fab857a3ebb965fd90c7f3b0a36cd3a19c29d2
parente060a0a318b45d6eee33ba59ccf9f5c3b76e5d29 (diff)
downloadironic-2752c73b3d15f47dfd9c42068169bc762b132d85.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 136499db8..cb22f08a9 100644
--- a/ironic/common/pxe_utils.py
+++ b/ironic/common/pxe_utils.py
@@ -232,10 +232,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
@@ -641,6 +644,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 491e4a883..7a2f60fad 100644
--- a/ironic/conductor/utils.py
+++ b/ironic/conductor/utils.py
@@ -893,7 +893,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
@@ -903,9 +903,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 673e4c664..7e50e96b8 100644
--- a/ironic/drivers/modules/deploy_utils.py
+++ b/ironic/drivers/modules/deploy_utils.py
@@ -1428,3 +1428,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: %(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 299bea3f1..9afa06dcd 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 86b6a5cba..f558b07c6 100644
--- a/ironic/tests/unit/common/test_pxe_utils.py
+++ b/ironic/tests/unit/common/test_pxe_utils.py
@@ -810,11 +810,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'
@@ -1053,6 +1049,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 2f59014c3..3c7c4fdf5 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.