From 606edbd13efd6ccc7f01afa447f076ae83fef19b Mon Sep 17 00:00:00 2001 From: Julia Kreger Date: Thu, 22 Feb 2024 11:45:01 -0800 Subject: [PATCH] neutron: do not error if no cleaning/provisioning on launch In the early days of the neutron network interface, we had a hard launch failure added to prevent ironic.conf from having a neutron network configuration which was not valid when the neutron network interface was in use. But as time has moved on, these settings became node-settable, and ironic configuration largely became mutable as well, so they can always be added after the process has been launched. But we kept the error being returned. Which doesn't make sense now that it can always be back-filled into a working state or just entirely be "user supplied" via the API by an appropriate user. Closes-Bug: 2054728 Change-Id: I33e76929ca9bf7869b3b4ef4d6501e692cf0a922 (cherry picked from commit 50ced3a3fab28af50951d39bbb76e561818aee44) --- ironic/drivers/modules/network/neutron.py | 18 ++---------------- .../drivers/modules/network/test_neutron.py | 12 ++++-------- ...hout-neutron-networks-d4aa21654f9c07bf.yaml | 9 +++++++++ 3 files changed, 15 insertions(+), 24 deletions(-) create mode 100644 releasenotes/notes/permit-conductor-to-start-without-neutron-networks-d4aa21654f9c07bf.yaml diff --git a/ironic/drivers/modules/network/neutron.py b/ironic/drivers/modules/network/neutron.py index 2503ea84b6..bf4b635362 100644 --- a/ironic/drivers/modules/network/neutron.py +++ b/ironic/drivers/modules/network/neutron.py @@ -33,22 +33,6 @@ class NeutronNetwork(common.NeutronVIFPortIDMixin, base.NetworkInterface): """Neutron v2 network interface""" - def __init__(self): - failures = [] - cleaning_net = CONF.neutron.cleaning_network - if not cleaning_net: - failures.append('cleaning_network') - - provisioning_net = CONF.neutron.provisioning_network - if not provisioning_net: - failures.append('provisioning_network') - - if failures: - raise exception.DriverLoadError( - driver=self.__class__.__name__, - reason=(_('The following [neutron] group configuration ' - 'options are missing: %s') % ', '.join(failures))) - def validate(self, task): """Validates the network interface. @@ -57,6 +41,8 @@ class NeutronNetwork(common.NeutronVIFPortIDMixin, is invalid. :raises: MissingParameterValue, if some parameters are missing. """ + # NOTE(TheJulia): These are the minimal networks needed for + # the neutron network interface to function. self.get_cleaning_network_uuid(task) self.get_provisioning_network_uuid(task) diff --git a/ironic/tests/unit/drivers/modules/network/test_neutron.py b/ironic/tests/unit/drivers/modules/network/test_neutron.py index 665a674a67..71ce579847 100644 --- a/ironic/tests/unit/drivers/modules/network/test_neutron.py +++ b/ironic/tests/unit/drivers/modules/network/test_neutron.py @@ -85,18 +85,14 @@ class NeutronInterfaceTestCase(db_base.DbTestCase): self.interface.port_changed(task, port) mock_p_changed.assert_called_once_with(self.interface, task, port) - def test_init_incorrect_provisioning_net(self): - self.config(provisioning_network=None, group='neutron') - self.assertRaises(exception.DriverLoadError, neutron.NeutronNetwork) - self.config(provisioning_network=uuidutils.generate_uuid(), - group='neutron') - self.config(cleaning_network=None, group='neutron') - self.assertRaises(exception.DriverLoadError, neutron.NeutronNetwork) - @mock.patch.object(neutron_common, 'validate_network', autospec=True) def test_validate(self, validate_mock): with task_manager.acquire(self.context, self.node.id) as task: self.interface.validate(task) + # NOTE(TheJulia): This tests validates the calls are made. + # When not mocked out completely, since Neutron is consulted + # on validity of the name or UUID as well, the validate_network + # method gets called which rasies a validate parsable error. self.assertEqual([mock.call(CONF.neutron.cleaning_network, 'cleaning network', context=task.context), diff --git a/releasenotes/notes/permit-conductor-to-start-without-neutron-networks-d4aa21654f9c07bf.yaml b/releasenotes/notes/permit-conductor-to-start-without-neutron-networks-d4aa21654f9c07bf.yaml new file mode 100644 index 0000000000..6e4f7e2501 --- /dev/null +++ b/releasenotes/notes/permit-conductor-to-start-without-neutron-networks-d4aa21654f9c07bf.yaml @@ -0,0 +1,9 @@ +--- +fixes: + - | + Fixes an issue where the conductor service would fail to launch when + the ``neutron`` network_interface setting was enabled, and no global + ``cleaning_network`` or ``provisioning_network`` is set in `ironic.conf.` + These settings have long been able to be applied on a per-node basis via + the API. As such, the service can now be started and will error on node + validation calls, as designed for drivers missing networking parameters.