Skip to content

Commit 951e2c7

Browse files
committed
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 dfe6947)
1 parent a4b8c97 commit 951e2c7

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

neutron/plugins/ml2/drivers/ovn/mech_driver/ovsdb/maintenance.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -827,7 +827,11 @@ def update_port_virtual_type(self):
827827
if lsp.type != '':
828828
continue
829829

830-
port = self._ovn_client._plugin.get_port(context, lsp.name)
830+
try:
831+
port = self._ovn_client._plugin.get_port(context, lsp.name)
832+
except n_exc.PortNotFound:
833+
continue
834+
831835
for ip in port.get('fixed_ips', []):
832836
if utils.get_virtual_port_parents(
833837
self._nb_idl, ip['ip_address'], port['network_id'],

neutron/tests/unit/plugins/ml2/drivers/ovn/mech_driver/ovsdb/test_maintenance.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
from neutron.tests.unit import fake_resources as fakes
3131
from neutron.tests.unit.plugins.ml2 import test_security_group as test_sg
3232
from neutron.tests.unit import testlib_api
33+
from neutron_lib import exceptions as n_exc
3334

3435

3536
class TestSchemaAwarePeriodicsBase(testlib_api.SqlTestCaseLight):
@@ -599,10 +600,13 @@ def test_update_port_virtual_type(self, *args):
599600
attrs={'name': 'lsp0', 'type': ''})
600601
lsp1 = fakes.FakeOvsdbRow.create_one_ovsdb_row(
601602
attrs={'name': 'lsp1', 'type': constants.LSP_TYPE_VIRTUAL})
603+
lsp2 = fakes.FakeOvsdbRow.create_one_ovsdb_row(
604+
attrs={'name': 'lsp2_not_present_in_neutron_db', 'type': ''})
602605
port0 = {'fixed_ips': [{'ip_address': mock.ANY}],
603606
'network_id': mock.ANY, 'id': mock.ANY}
604-
nb_idl.lsp_list.return_value.execute.return_value = (lsp0, lsp1)
605-
self.fake_ovn_client._plugin.get_port.return_value = port0
607+
nb_idl.lsp_list.return_value.execute.return_value = (lsp0, lsp1, lsp2)
608+
self.fake_ovn_client._plugin.get_port.side_effect = [
609+
port0, n_exc.PortNotFound(port_id=mock.ANY)]
606610

607611
self.assertRaises(
608612
periodics.NeverAgain, self.periodic.update_port_virtual_type)

0 commit comments

Comments
 (0)