[OVN] Check if the LRP exists in `check_provider_distributed_ports`
The method ``check_provider_distributed_ports`` retrieves all Neutron database router ports in order to check the corresponding OVN LRP ``reside-on-redirect-chassis`` option. Since [1], ML2/OVN routers can have a specific flavor and the Logical_Router_Port can be missing in the OVN database. This patch checks if the Logical_Router_Port is present before updating it. [1]https://review.opendev.org/q/topic:%22router-flavor-ovn%22 Closes-Bug: #2092474 Change-Id: I0d8e364b1ec798fd940c494f59b78c6c0bcdc7b7
This commit is contained in:
@@ -700,7 +700,7 @@ class DBInconsistenciesPeriodics(SchemaAwarePeriodicsBase):
|
||||
rp['device_id']))
|
||||
lrp_name = utils.ovn_lrouter_port_name(rp['id'])
|
||||
lrp = self._nb_idl.get_lrouter_port(lrp_name)
|
||||
if lrp.options.get(
|
||||
if lrp and lrp.options.get(
|
||||
ovn_const.LRP_OPTIONS_RESIDE_REDIR_CH) != expected_value:
|
||||
opt = {ovn_const.LRP_OPTIONS_RESIDE_REDIR_CH: expected_value}
|
||||
cmds.append(self._nb_idl.db_set(
|
||||
|
||||
@@ -682,7 +682,8 @@ class TestDBInconsistenciesPeriodics(testlib_api.SqlTestCaseLight,
|
||||
self._test_check_redirect_type_router_gateway_ports(
|
||||
networks, False, flavored_router=True)
|
||||
|
||||
def _test_check_provider_distributed_ports(self, opt_value=None):
|
||||
def _test_check_provider_distributed_ports(self, opt_value=None,
|
||||
flavor_router=False):
|
||||
fake_net0 = {'id': 'net0'}
|
||||
fake_net1 = {'id': 'net1'}
|
||||
fake_port0 = {'id': 'port0', 'device_id': 'device0'}
|
||||
@@ -695,10 +696,13 @@ class TestDBInconsistenciesPeriodics(testlib_api.SqlTestCaseLight,
|
||||
(self.fake_ovn_client._get_reside_redir_for_gateway_port
|
||||
.return_value) = 'true'
|
||||
|
||||
fake_lrp = fakes.FakeOvsdbRow.create_one_ovsdb_row(
|
||||
attrs={
|
||||
'name': 'lrp',
|
||||
'options': {constants.LRP_OPTIONS_RESIDE_REDIR_CH: opt_value}})
|
||||
if flavor_router:
|
||||
fake_lrp = None
|
||||
else:
|
||||
fake_lrp = fakes.FakeOvsdbRow.create_one_ovsdb_row(
|
||||
attrs={'name': 'lrp',
|
||||
'options': {
|
||||
constants.LRP_OPTIONS_RESIDE_REDIR_CH: opt_value}})
|
||||
self.fake_ovn_client._nb_idl.get_lrouter_port.return_value = fake_lrp
|
||||
|
||||
# Invoke the periodic method, it meant to run only once at startup
|
||||
@@ -726,6 +730,12 @@ class TestDBInconsistenciesPeriodics(testlib_api.SqlTestCaseLight,
|
||||
self.fake_ovn_client._nb_idl.db_set.assert_has_calls(
|
||||
expected_calls)
|
||||
|
||||
def test_check_provider_distributed_ports_flavor_router(self):
|
||||
self._test_check_provider_distributed_ports(opt_value=mock.ANY,
|
||||
flavor_router=True)
|
||||
# No LRPs are created, not LRP ``db_set`` can be done.
|
||||
self.fake_ovn_client._nb_idl.db_set.assert_not_called()
|
||||
|
||||
def _test_check_baremetal_ports_dhcp_options(self, dhcp_disabled=False):
|
||||
cfg.CONF.set_override('disable_ovn_dhcp_for_baremetal_ports',
|
||||
dhcp_disabled, group='ovn')
|
||||
|
||||
Reference in New Issue
Block a user