Merge "Flip require_managed_boot to True for the new agent inspection"

This commit is contained in:
Zuul 2024-01-23 16:26:46 +00:00 committed by Gerrit Code Review
commit 3d5ef6a7e9
6 changed files with 38 additions and 9 deletions

View File

@ -57,8 +57,9 @@ Unmanaged inspection was the only inspection mode before the Ussuri release,
and it is still used when the node's boot cannot be configured by the and it is still used when the node's boot cannot be configured by the
conductor. The options described above do not affect unmanaged inspection. conductor. The options described above do not affect unmanaged inspection.
Unmanaged inspection is currently enabled by default but will be disabled Because of the complex installation and operation requirements, unmanaged
in the near future. To enable it, set ``require_managed_boot`` to ``False``: inspection is disabled by default. To enable it, set ``require_managed_boot``
to ``False``:
.. code-block:: ini .. code-block:: ini

View File

@ -59,14 +59,18 @@ opts = [
help=_('endpoint to use as a callback for posting back ' help=_('endpoint to use as a callback for posting back '
'introspection data when boot is managed by ironic. ' 'introspection data when boot is managed by ironic. '
'Standard keystoneauth options are used by default.')), 'Standard keystoneauth options are used by default.')),
# TODO(dtantsur): change the default to True when ironic-inspector is no
# longer supported (and update the help string).
cfg.BoolOpt('require_managed_boot', default=None, cfg.BoolOpt('require_managed_boot', default=None,
help=_('require that the in-band inspection boot is fully ' help=_('require that the in-band inspection boot is fully '
'managed by the node\'s boot interface. Set this to ' 'managed by the node\'s boot interface. Set this to '
'True if your installation does not have a separate ' 'False if your installation has a separate (i)PXE boot '
'(i)PXE boot environment for node discovery. Set ' 'environment for node discovery or unmanaged '
'to False if you need to inspect nodes that are not ' 'inspection. You may need to set it to False to '
'supported by boot interfaces (e.g. because they ' 'inspect nodes that are not supported by boot '
'don\'t have ports).')), 'interfaces (e.g. because they don\'t have ports). '
'The default value depends on which inspect interface '
'is used: inspector uses False, agent - True.')),
cfg.StrOpt('add_ports', cfg.StrOpt('add_ports',
default='pxe', default='pxe',
help=_('Which MAC addresses to add as ports during ' help=_('Which MAC addresses to add as ports during '

View File

@ -38,6 +38,8 @@ CONF = cfg.CONF
class AgentInspect(common.Common): class AgentInspect(common.Common):
"""In-band inspection.""" """In-band inspection."""
default_require_managed_boot = True
def __init__(self): def __init__(self):
super().__init__() super().__init__()
self.hooks = hooks_base.validate_inspection_hooks() self.hooks = hooks_base.validate_inspection_hooks()

View File

@ -153,6 +153,8 @@ def prepare_managed_inspection(task, endpoint):
class Common(base.InspectInterface): class Common(base.InspectInterface):
default_require_managed_boot = False
def __init__(self): def __init__(self):
super().__init__() super().__init__()
if CONF.inspector.require_managed_boot is None: if CONF.inspector.require_managed_boot is None:
@ -161,6 +163,11 @@ class Common(base.InspectInterface):
"Set it to an explicit boolean value to avoid a " "Set it to an explicit boolean value to avoid a "
"potential breakage.") "potential breakage.")
def _require_managed_boot(self):
return (CONF.inspector.require_managed_boot
if CONF.inspector.require_managed_boot is not None
else self.default_require_managed_boot)
def get_properties(self): def get_properties(self):
"""Return the properties of the interface. """Return the properties of the interface.
@ -177,7 +184,7 @@ class Common(base.InspectInterface):
:raises: UnsupportedDriverExtension :raises: UnsupportedDriverExtension
""" """
utils.parse_kernel_params(CONF.inspector.extra_kernel_params) utils.parse_kernel_params(CONF.inspector.extra_kernel_params)
if CONF.inspector.require_managed_boot: if self._require_managed_boot():
ironic_manages_boot(task, raise_exc=True) ironic_manages_boot(task, raise_exc=True)
def inspect_hardware(self, task): def inspect_hardware(self, task):
@ -197,7 +204,7 @@ class Common(base.InspectInterface):
' on node %s.', task.node.uuid) ' on node %s.', task.node.uuid)
manage_boot = ironic_manages_boot( manage_boot = ironic_manages_boot(
task, raise_exc=CONF.inspector.require_managed_boot) task, raise_exc=self._require_managed_boot())
utils.set_node_nested_field(task.node, 'driver_internal_info', utils.set_node_nested_field(task.node, 'driver_internal_info',
_IRONIC_MANAGES_BOOT, manage_boot) _IRONIC_MANAGES_BOOT, manage_boot)

View File

@ -42,6 +42,7 @@ class InspectHardwareTestCase(db_base.DbTestCase):
self.driver = self.task.driver self.driver = self.task.driver
def test_unmanaged_ok(self, mock_create_ports_if_not_exist): def test_unmanaged_ok(self, mock_create_ports_if_not_exist):
CONF.set_override('require_managed_boot', False, group='inspector')
self.driver.boot.validate_inspection.side_effect = ( self.driver.boot.validate_inspection.side_effect = (
exception.UnsupportedDriverExtension('')) exception.UnsupportedDriverExtension(''))
self.assertEqual(states.INSPECTWAIT, self.assertEqual(states.INSPECTWAIT,
@ -58,6 +59,12 @@ class InspectHardwareTestCase(db_base.DbTestCase):
self.assertFalse(self.driver.network.remove_inspection_network.called) self.assertFalse(self.driver.network.remove_inspection_network.called)
self.assertFalse(self.driver.boot.clean_up_ramdisk.called) self.assertFalse(self.driver.boot.clean_up_ramdisk.called)
def test_unmanaged_disallowed(self, mock_create_ports_if_not_exist):
self.driver.boot.validate_inspection.side_effect = (
exception.UnsupportedDriverExtension(''))
self.assertRaises(exception.UnsupportedDriverExtension,
self.iface.inspect_hardware, self.task)
@mock.patch.object(deploy_utils, 'get_ironic_api_url', autospec=True) @mock.patch.object(deploy_utils, 'get_ironic_api_url', autospec=True)
def test_managed_ok(self, mock_get_url, mock_create_ports_if_not_exist): def test_managed_ok(self, mock_get_url, mock_create_ports_if_not_exist):
endpoint = 'http://192.169.0.42:6385/v1' endpoint = 'http://192.169.0.42:6385/v1'

View File

@ -0,0 +1,8 @@
---
upgrade:
- |
The default value of the configuration option
``[inspector]require_managed_boot`` is now ``True`` for the newer ``agent``
inspect interface. The older ``inspector`` implementation is not affected.
Operators with deployments that support unmanaged inspection must set
this value to ``False`` explicitly.