summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitry Tantsur <dtantsur@protonmail.com>2022-08-15 16:42:19 +0200
committerJay Faulkner <jay@jvf.cc>2022-09-16 13:04:16 -0700
commit66373aadc04974de0838abc43c5f9cf113781f1f (patch)
treefc13d02a227c6f4c0634553e2bb41099ec0e3d54
parentff70069375521b735df73046f26c20b308978b11 (diff)
downloadironic-66373aadc04974de0838abc43c5f9cf113781f1f.tar.gz
Do not reboot into nowhere after BIOS settings with fast-track
Currently, the prepare_ramdisk implementation of the redfish-virtual-media boot interface skips configuring an ISO in fast-track mode. When rebooting after BIOS/RAID settings changes, we need to enforce the correct ISO configuration. Conflicts: ironic/drivers/modules/deploy_utils.py ironic/drivers/modules/redfish/bios.py Change-Id: Ibdfe0775065f3b27478305dd18929a291df3ee3c (cherry picked from commit 89f421b166915a22626dcb919382ce13f4588973) (cherry picked from commit d85d7f8ac52f289b7b01096c65757b68791f4bd4)
-rw-r--r--ironic/drivers/modules/deploy_utils.py26
-rw-r--r--ironic/drivers/modules/redfish/bios.py26
-rw-r--r--ironic/tests/unit/drivers/modules/redfish/test_bios.py32
-rw-r--r--releasenotes/notes/fast-track-bios-fa9ae685c151dd24.yaml6
4 files changed, 64 insertions, 26 deletions
diff --git a/ironic/drivers/modules/deploy_utils.py b/ironic/drivers/modules/deploy_utils.py
index 673e4c664..4e0f29685 100644
--- a/ironic/drivers/modules/deploy_utils.py
+++ b/ironic/drivers/modules/deploy_utils.py
@@ -1406,6 +1406,32 @@ def set_async_step_flags(node, reboot=None, skip_current_step=None,
node.save()
+def prepare_agent_boot(task):
+ """Prepare booting the agent on the node.
+
+ :param task: a TaskManager instance.
+ """
+ deploy_opts = build_agent_options(task.node)
+ task.driver.boot.prepare_ramdisk(task, deploy_opts)
+
+
+def reboot_to_finish_step(task):
+ """Reboot the node into IPA to finish a deploy/clean step.
+
+ :param task: a TaskManager instance.
+ :returns: states.CLEANWAIT if cleaning operation in progress
+ or states.DEPLOYWAIT if deploy operation in progress.
+ """
+ if manager_utils.is_fast_track(task):
+ LOG.debug('Forcing power off on node %s for a clean reboot into '
+ 'the agent image', task.node)
+ manager_utils.node_power_action(task, states.POWER_OFF)
+ prepare_agent_boot(task)
+
+ manager_utils.node_power_action(task, states.REBOOT)
+ return get_async_step_return_state(task.node)
+
+
def get_root_device_for_deploy(node):
"""Get a root device requested for deployment or None.
diff --git a/ironic/drivers/modules/redfish/bios.py b/ironic/drivers/modules/redfish/bios.py
index a4fc8e6fe..a5f7faf8a 100644
--- a/ironic/drivers/modules/redfish/bios.py
+++ b/ironic/drivers/modules/redfish/bios.py
@@ -19,7 +19,6 @@ from oslo_utils import importutils
from ironic.common import exception
from ironic.common.i18n import _
from ironic.common import states
-from ironic.conductor import task_manager
from ironic.conductor import utils as manager_utils
from ironic.drivers import base
from ironic.drivers.modules import deploy_utils
@@ -189,9 +188,8 @@ class RedfishBIOS(base.BIOSInterface):
LOG.error(error_msg)
raise exception.RedfishError(error=error_msg)
- self.post_reset(task)
self._set_reboot(task)
- return deploy_utils.get_async_step_return_state(task.node)
+ return self.post_reset(task)
else:
current_attrs = bios.attributes
LOG.debug('Post factory reset, BIOS configuration for node '
@@ -248,9 +246,8 @@ class RedfishBIOS(base.BIOSInterface):
LOG.error(error_msg)
raise exception.RedfishError(error=error_msg)
- self.post_configuration(task, settings)
self._set_reboot_requested(task, attributes)
- return deploy_utils.get_async_step_return_state(task.node)
+ return self.post_configuration(task, settings)
else:
# Step 2: Verify requested BIOS settings applied
requested_attrs = info.get('requested_bios_attrs')
@@ -271,9 +268,7 @@ class RedfishBIOS(base.BIOSInterface):
:param task: a TaskManager instance containing the node to act on.
"""
- deploy_opts = deploy_utils.build_agent_options(task.node)
- task.driver.boot.prepare_ramdisk(task, deploy_opts)
- self._reboot(task)
+ return deploy_utils.reboot_to_finish_step(task)
def post_configuration(self, task, settings):
"""Perform post configuration action to store the BIOS settings.
@@ -286,9 +281,7 @@ class RedfishBIOS(base.BIOSInterface):
:param task: a TaskManager instance containing the node to act on.
:param settings: a list of BIOS settings to be updated.
"""
- deploy_opts = deploy_utils.build_agent_options(task.node)
- task.driver.boot.prepare_ramdisk(task, deploy_opts)
- self._reboot(task)
+ return deploy_utils.reboot_to_finish_step(task)
def get_properties(self):
"""Return the properties of the interface.
@@ -328,17 +321,6 @@ class RedfishBIOS(base.BIOSInterface):
LOG.debug('Verification of BIOS settings for node %(node_uuid)s '
'successful.', {'node_uuid': task.node.uuid})
- @task_manager.require_exclusive_lock
- def _reboot(self, task):
- """Reboot the target Redfish service.
-
- :param task: a TaskManager instance containing the node to act on.
- :raises: InvalidParameterValue when the wrong state is specified
- or the wrong driver info is specified.
- :raises: RedfishError on an error from the Sushy library
- """
- manager_utils.node_power_action(task, states.REBOOT)
-
def _set_reboot(self, task):
"""Set driver_internal_info flags for deployment or cleaning reboot.
diff --git a/ironic/tests/unit/drivers/modules/redfish/test_bios.py b/ironic/tests/unit/drivers/modules/redfish/test_bios.py
index a0ef28f5c..2ff3235fd 100644
--- a/ironic/tests/unit/drivers/modules/redfish/test_bios.py
+++ b/ironic/tests/unit/drivers/modules/redfish/test_bios.py
@@ -165,13 +165,16 @@ class RedfishBiosTestCase(db_base.DbTestCase):
mock_setting_list.delete.assert_called_once_with(
task.context, task.node.id, delete_names)
+ @mock.patch.object(manager_utils, 'is_fast_track', autospec=True)
@mock.patch.object(redfish_boot.RedfishVirtualMediaBoot, 'prepare_ramdisk',
spec_set=True, autospec=True)
@mock.patch.object(deploy_utils, 'build_agent_options', autospec=True)
@mock.patch.object(redfish_utils, 'get_system', autospec=True)
@mock.patch.object(manager_utils, 'node_power_action', autospec=True)
def _test_step_pre_reboot(self, mock_power_action, mock_get_system,
- mock_build_agent_options, mock_prepare):
+ mock_build_agent_options, mock_prepare,
+ mock_fast_track, fast_track=False):
+ mock_fast_track.return_value = fast_track
if self.node.clean_step:
step_data = self.node.clean_step
check_fields = ['cleaning_reboot', 'skip_current_clean_step']
@@ -197,7 +200,13 @@ class RedfishBiosTestCase(db_base.DbTestCase):
bios.supported_apply_times = []
ret = task.driver.bios.apply_configuration(task, data)
mock_get_system.assert_called_with(task.node)
- mock_power_action.assert_called_once_with(task, states.REBOOT)
+ if fast_track:
+ mock_power_action.assert_has_calls([
+ mock.call(task, states.POWER_OFF),
+ mock.call(task, states.REBOOT),
+ ])
+ else:
+ mock_power_action.assert_called_once_with(task, states.REBOOT)
if step == 'factory_reset':
bios.reset_bios.assert_called_once()
if step == 'apply_configuration':
@@ -205,8 +214,8 @@ class RedfishBiosTestCase(db_base.DbTestCase):
attributes, apply_time=None)
mock_build_agent_options.assert_called_once_with(task.node)
mock_prepare.assert_called_once_with(mock.ANY, task, {'a': 'b'})
- info = task.node.driver_internal_info
- self.assertTrue(all(x in info for x in check_fields))
+ for field in check_fields:
+ self.assertIn(field, task.node.driver_internal_info)
self.assertEqual(expected_ret, ret)
def test_factory_reset_step_pre_reboot_cleaning(self):
@@ -221,6 +230,12 @@ class RedfishBiosTestCase(db_base.DbTestCase):
self.node.save()
self._test_step_pre_reboot()
+ def test_factory_reset_step_pre_reboot_fast_track(self):
+ self.node.clean_step = {'priority': 100, 'interface': 'bios',
+ 'step': 'factory_reset', 'argsinfo': {}}
+ self.node.save()
+ self._test_step_pre_reboot(fast_track=True)
+
def test_apply_conf_step_pre_reboot_cleaning(self):
data = [{'name': 'ProcTurboMode', 'value': 'Disabled'},
{'name': 'NicBoot1', 'value': 'NetworkBoot'}]
@@ -239,6 +254,15 @@ class RedfishBiosTestCase(db_base.DbTestCase):
self.node.save()
self._test_step_pre_reboot()
+ def test_apply_conf_step_pre_reboot_fast_track(self):
+ data = [{'name': 'ProcTurboMode', 'value': 'Disabled'},
+ {'name': 'NicBoot1', 'value': 'NetworkBoot'}]
+ self.node.clean_step = {'priority': 100, 'interface': 'bios',
+ 'step': 'apply_configuration',
+ 'argsinfo': {'settings': data}}
+ self.node.save()
+ self._test_step_pre_reboot(fast_track=True)
+
@mock.patch.object(redfish_utils, 'get_system', autospec=True)
def _test_step_post_reboot(self, mock_get_system,
attributes_after_reboot=None):
diff --git a/releasenotes/notes/fast-track-bios-fa9ae685c151dd24.yaml b/releasenotes/notes/fast-track-bios-fa9ae685c151dd24.yaml
new file mode 100644
index 000000000..b4a8004f7
--- /dev/null
+++ b/releasenotes/notes/fast-track-bios-fa9ae685c151dd24.yaml
@@ -0,0 +1,6 @@
+---
+fixes:
+ - |
+ Fixes rebooting into the agent after changing BIOS settings in fast-track
+ mode with the ``redfish-virtual-media`` boot interface. Previously, the ISO
+ would not be configured.