Browse Source

Respect driver_info.force_persistent_boot_device

This option has been created to work around flacky hardware that
does not work correctly with temporary boot. However, ironic-inspector
unconditionally uses persistent=False. This change fixes it.

Story: #2007093
Task: #38126
Change-Id: Ie21e5beeec6188e3b979c28167e575e1c37087ee
(cherry picked from commit f8e26aa088)
tags/9.2.1^0
Dmitry Tantsur 1 month ago
parent
commit
578ab43b28
3 changed files with 70 additions and 2 deletions
  1. +13
    -2
      ironic_inspector/introspect.py
  2. +52
    -0
      ironic_inspector/test/unit/test_introspect.py
  3. +5
    -0
      releasenotes/notes/persistent-boot-207b32257a97451e.yaml

+ 13
- 2
ironic_inspector/introspect.py View File

@@ -17,6 +17,7 @@ import time

from eventlet import semaphore
from oslo_config import cfg
from oslo_utils import strutils

from ironic_inspector.common.i18n import _
from ironic_inspector.common import ironic as ir_utils
@@ -82,6 +83,15 @@ def _background_introspect(node_info, ironic):
_background_introspect_locked(node_info, ironic)


def _persistent_ramdisk_boot(node):
"""If the ramdisk should be configured as a persistent boot device."""
value = node.driver_info.get('force_persistent_boot_device', 'Default')
if value in {'Always', 'Default', 'Never'}:
return value == 'Always'
else:
return strutils.bool_from_string(value, False)


def _background_introspect_locked(node_info, ironic):
# TODO(dtantsur): pagination
macs = list(node_info.ports())
@@ -104,8 +114,9 @@ def _background_introspect_locked(node_info, ironic):

if node_info.manage_boot:
try:
ironic.node.set_boot_device(node_info.uuid, 'pxe',
persistent=False)
ironic.node.set_boot_device(
node_info.uuid, 'pxe',
persistent=_persistent_ramdisk_boot(node_info.node()))
except Exception as exc:
raise utils.Error(_('Failed to set boot device to PXE: %s') % exc,
node_info=node_info)

+ 52
- 0
ironic_inspector/test/unit/test_introspect.py View File

@@ -234,6 +234,58 @@ class TestIntrospect(BaseTest):
cli.node.set_power_state.assert_called_once_with(self.uuid,
'reboot')

def test_forced_persistent_boot(self, client_mock, start_mock):
self.node.driver_info['force_persistent_boot_device'] = 'Always'
cli = self._prepare(client_mock)
start_mock.return_value = self.node_info

introspect.introspect(self.node.uuid)

cli.node.get.assert_called_once_with(self.uuid)
cli.node.validate.assert_called_once_with(self.uuid)

start_mock.assert_called_once_with(self.uuid,
bmc_address=[self.bmc_address],
manage_boot=True,
ironic=cli)
self.node_info.ports.assert_called_once_with()
self.node_info.add_attribute.assert_called_once_with('mac',
self.macs)
self.sync_filter_mock.assert_called_with(cli)
cli.node.set_boot_device.assert_called_once_with(self.uuid,
'pxe',
persistent=True)
cli.node.set_power_state.assert_called_once_with(self.uuid,
'reboot')
self.node_info.acquire_lock.assert_called_once_with()
self.node_info.release_lock.assert_called_once_with()

def test_forced_persistent_boot_compat(self, client_mock, start_mock):
self.node.driver_info['force_persistent_boot_device'] = 'true'
cli = self._prepare(client_mock)
start_mock.return_value = self.node_info

introspect.introspect(self.node.uuid)

cli.node.get.assert_called_once_with(self.uuid)
cli.node.validate.assert_called_once_with(self.uuid)

start_mock.assert_called_once_with(self.uuid,
bmc_address=[self.bmc_address],
manage_boot=True,
ironic=cli)
self.node_info.ports.assert_called_once_with()
self.node_info.add_attribute.assert_called_once_with('mac',
self.macs)
self.sync_filter_mock.assert_called_with(cli)
cli.node.set_boot_device.assert_called_once_with(self.uuid,
'pxe',
persistent=True)
cli.node.set_power_state.assert_called_once_with(self.uuid,
'reboot')
self.node_info.acquire_lock.assert_called_once_with()
self.node_info.release_lock.assert_called_once_with()

def test_no_lookup_attrs(self, client_mock, start_mock):
cli = self._prepare(client_mock)
self.node_info.ports.return_value = []

+ 5
- 0
releasenotes/notes/persistent-boot-207b32257a97451e.yaml View File

@@ -0,0 +1,5 @@
---
fixes:
- |
Introspection now respects the ``force_persistent_boot_device``
parameter in a node's ``driver_info``.

Loading…
Cancel
Save