diff options
author | Rodolfo Alonso Hernandez <ralonsoh@redhat.com> | 2022-12-08 06:30:14 +0100 |
---|---|---|
committer | Rodolfo Alonso Hernandez <ralonsoh@redhat.com> | 2022-12-11 01:09:13 +0100 |
commit | d0b8c5f332ec5a08679d4270ea6404d7651c41c2 (patch) | |
tree | ef450390fc56a14b12ee254c043ed704a60af938 | |
parent | 6358c2fa56fcd84337cfe074dba96abb3b302261 (diff) | |
download | neutron-d0b8c5f332ec5a08679d4270ea6404d7651c41c2.tar.gz |
Check if port exists in ``update_port_virtual_type`` method
During the OVN DB inconsistency check, a OVN LSP could not be present
in the Neutron DB. In this case, continue processing other LSPs and
let other ``DBInconsistenciesPeriodics`` methods to resolve this
issue.
Closes-Bug: #1999517
Conflicts:
neutron/tests/unit/plugins/ml2/drivers/ovn/mech_driver/ovsdb/test_maintenance.py
Change-Id: Ifb8bdccf6819f7f8af1abd3b82ccb1cd2e4c2fb8
(cherry picked from commit dfe69472a82d7eee96299122c8a9520aeed73ddd)
(cherry picked from commit 951e2c74ae0baff84e98b5580071d09db95f00d5)
-rw-r--r-- | neutron/plugins/ml2/drivers/ovn/mech_driver/ovsdb/maintenance.py | 6 | ||||
-rw-r--r-- | neutron/tests/unit/plugins/ml2/drivers/ovn/mech_driver/ovsdb/test_maintenance.py | 8 |
2 files changed, 11 insertions, 3 deletions
diff --git a/neutron/plugins/ml2/drivers/ovn/mech_driver/ovsdb/maintenance.py b/neutron/plugins/ml2/drivers/ovn/mech_driver/ovsdb/maintenance.py index 4e39683b39..44b92859e9 100644 --- a/neutron/plugins/ml2/drivers/ovn/mech_driver/ovsdb/maintenance.py +++ b/neutron/plugins/ml2/drivers/ovn/mech_driver/ovsdb/maintenance.py @@ -759,7 +759,11 @@ class DBInconsistenciesPeriodics(SchemaAwarePeriodicsBase): if lsp.type != '': continue - port = self._ovn_client._plugin.get_port(context, lsp.name) + try: + port = self._ovn_client._plugin.get_port(context, lsp.name) + except n_exc.PortNotFound: + continue + for ip in port.get('fixed_ips', []): if utils.get_virtual_port_parents( self._nb_idl, ip['ip_address'], port['network_id'], diff --git a/neutron/tests/unit/plugins/ml2/drivers/ovn/mech_driver/ovsdb/test_maintenance.py b/neutron/tests/unit/plugins/ml2/drivers/ovn/mech_driver/ovsdb/test_maintenance.py index bcf105d98c..010d01dbef 100644 --- a/neutron/tests/unit/plugins/ml2/drivers/ovn/mech_driver/ovsdb/test_maintenance.py +++ b/neutron/tests/unit/plugins/ml2/drivers/ovn/mech_driver/ovsdb/test_maintenance.py @@ -28,6 +28,7 @@ from neutron.plugins.ml2.drivers.ovn.mech_driver.ovsdb import ovn_db_sync from neutron.tests.unit import fake_resources as fakes from neutron.tests.unit.plugins.ml2 import test_security_group as test_sg from neutron.tests.unit import testlib_api +from neutron_lib import exceptions as n_exc class TestSchemaAwarePeriodicsBase(testlib_api.SqlTestCaseLight): @@ -528,10 +529,13 @@ class TestDBInconsistenciesPeriodics(testlib_api.SqlTestCaseLight, attrs={'name': 'lsp0', 'type': ''}) lsp1 = fakes.FakeOvsdbRow.create_one_ovsdb_row( attrs={'name': 'lsp1', 'type': constants.LSP_TYPE_VIRTUAL}) + lsp2 = fakes.FakeOvsdbRow.create_one_ovsdb_row( + attrs={'name': 'lsp2_not_present_in_neutron_db', 'type': ''}) port0 = {'fixed_ips': [{'ip_address': mock.ANY}], 'network_id': mock.ANY, 'id': mock.ANY} - nb_idl.lsp_list.return_value.execute.return_value = (lsp0, lsp1) - self.fake_ovn_client._plugin.get_port.return_value = port0 + nb_idl.lsp_list.return_value.execute.return_value = (lsp0, lsp1, lsp2) + self.fake_ovn_client._plugin.get_port.side_effect = [ + port0, n_exc.PortNotFound(port_id=mock.ANY)] self.assertRaises( periodics.NeverAgain, self.periodic.update_port_virtual_type) |