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: c7091fb8e2), 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 <steniaraujo@lsd.ufcg.edu.br>
This commit is contained in:
Fellype Cavalcante 2017-07-13 10:22:29 -03:00 committed by Stenio Araujo
parent 5ea8d9f354
commit 049fd40719
5 changed files with 63 additions and 1 deletions

View File

@ -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
---------------

View File

@ -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 <node>
.. 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.

View File

@ -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)

View File

@ -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,

View File

@ -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.