diff --git a/doc/source/admin/drivers.rst b/doc/source/admin/drivers.rst index eef6e503ec..5418f745d9 100644 --- a/doc/source/admin/drivers.rst +++ b/doc/source/admin/drivers.rst @@ -13,6 +13,14 @@ nodes, and runs processes inside of a ramdisk. For more information on this, see :ref:`IPA`. +PXE Boot Interface +------------------ + +.. toctree:: + :maxdepth: 1 + + drivers/pxe + IPMITool driver --------------- diff --git a/doc/source/admin/drivers/pxe.rst b/doc/source/admin/drivers/pxe.rst new file mode 100644 index 0000000000..21084f5c21 --- /dev/null +++ b/doc/source/admin/drivers/pxe.rst @@ -0,0 +1,26 @@ +.. pxe: + +============================== +Configuring PXE boot interface +============================== + +Enable persistent boot device for deploy/clean operation +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Ironic uses non-persistent boot for cleaning/deploying phases as default, +in PXE interface. For some drivers, a persistent change is far more +costly than a non-persistent one, so this can bring performance improvements. + +Enable persistent boot device on node +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +1. Set the flag ``force_persistent_boot_device`` to ``True`` in the node's ``driver_info``:: + + $ openstack baremetal node set --driver-info force_persistent_boot_device=True + + .. note:: + It's recommended to check if the node's state has not changed as there + is no way of locking the node between these commands. + +Once the flag is present, the next cleaning and deploy steps will be done +with persistent boot for that node. diff --git a/ironic/drivers/modules/pxe.py b/ironic/drivers/modules/pxe.py index a2d27ef008..c9a7c5fda6 100644 --- a/ironic/drivers/modules/pxe.py +++ b/ironic/drivers/modules/pxe.py @@ -21,6 +21,7 @@ from ironic_lib import metrics_utils from ironic_lib import utils as ironic_utils from oslo_log import log as logging from oslo_utils import fileutils +from oslo_utils import strutils from ironic.common import boot_devices from ironic.common import dhcp_factory @@ -493,8 +494,11 @@ class PXEBoot(base.BootInterface): pxe_utils.create_pxe_config(task, pxe_options, pxe_config_template) + persistent = strutils.bool_from_string( + node.driver_info.get('force_persistent_boot_device', + False)) manager_utils.node_set_boot_device(task, boot_devices.PXE, - persistent=False) + persistent=persistent) if CONF.pxe.ipxe_enabled and CONF.pxe.ipxe_use_swift: pxe_info.pop('deploy_kernel', None) diff --git a/ironic/tests/unit/drivers/modules/test_pxe.py b/ironic/tests/unit/drivers/modules/test_pxe.py index df3d675027..849a7c8e34 100644 --- a/ironic/tests/unit/drivers/modules/test_pxe.py +++ b/ironic/tests/unit/drivers/modules/test_pxe.py @@ -1199,6 +1199,21 @@ class PXEBootTestCase(db_base.DbTestCase): boot_devices.DISK, persistent=True) + @mock.patch.object(manager_utils, 'node_set_boot_device', autospec=True) + @mock.patch.object(pxe_utils, 'clean_up_pxe_config', autospec=True) + def test_is_force_persistent_boot_device_enabled( + self, clean_up_pxe_config_mock, set_boot_device_mock): + with task_manager.acquire(self.context, self.node.uuid) as task: + task.node.instance_info['capabilities'] = {'boot_option': 'local'} + task.driver.boot.prepare_instance(task) + clean_up_pxe_config_mock.assert_called_once_with(task) + driver_info = task.node.driver_info + driver_info['force_persistent _boot_device'] = True + task.node.driver_info = driver_info + set_boot_device_mock.assert_called_once_with(task, + boot_devices.DISK, + persistent=True) + @mock.patch.object(manager_utils, 'node_set_boot_device', autospec=True) @mock.patch.object(pxe_utils, 'clean_up_pxe_config', autospec=True) def test_prepare_instance_localboot_active(self, clean_up_pxe_config_mock, diff --git a/releasenotes/notes/flag_always_reboot-62468a7058b58823.yaml b/releasenotes/notes/flag_always_reboot-62468a7058b58823.yaml new file mode 100644 index 0000000000..d0ffb2231f --- /dev/null +++ b/releasenotes/notes/flag_always_reboot-62468a7058b58823.yaml @@ -0,0 +1,9 @@ +--- +features: + - | + Adds a boolean flag called ``force_persistent_boot_device`` into + a node's ``driver_info`` to enable persistent behavior when you + set the boot device during deploy and cleaning operations. This + flag will override a non-persistent behavior in the cleaning and + deploy process. + For more information, see https://bugs.launchpad.net/ironic/+bug/1703945.