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 dfe69472a8)
(cherry picked from commit 951e2c74ae)
This commit is contained in:
Rodolfo Alonso Hernandez 2022-12-08 06:30:14 +01:00
parent 6358c2fa56
commit d0b8c5f332
2 changed files with 11 additions and 3 deletions

View File

@ -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'],

View File

@ -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)