From 049fd407196c0eb5846f5ff63f2cbc482afa4d89 Mon Sep 17 00:00:00 2001 From: Fellype Cavalcante Date: Thu, 13 Jul 2017 10:22:29 -0300 Subject: [PATCH] Add a flag to always perform persistent boot on PXE interface With the proposal to solve the bug that PXE interface should be using non-persistent boot for cleaning/deploying phases as default(commit: c7091fb8e2898e526f8ce242f50096a2cabeb1fa), it's necessary to create a flag to enable persistent behavior when you set the boot device. This flag will override a non-persistent behavior in the cleaning and deploy process. Change-Id: I1f47393c17a3f5319fffd963ec0a016b41865c5d Closes-Bug: 1703945 Co-Authored-By: Stenio Araujo --- doc/source/admin/drivers.rst | 8 ++++++ doc/source/admin/drivers/pxe.rst | 26 +++++++++++++++++++ ironic/drivers/modules/pxe.py | 6 ++++- ironic/tests/unit/drivers/modules/test_pxe.py | 15 +++++++++++ .../flag_always_reboot-62468a7058b58823.yaml | 9 +++++++ 5 files changed, 63 insertions(+), 1 deletion(-) create mode 100644 doc/source/admin/drivers/pxe.rst create mode 100644 releasenotes/notes/flag_always_reboot-62468a7058b58823.yaml 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.