[stable only] Do not fail on missing logical router ports

set_gateway_mtu runs for all the gateway ports for a network
and if one of the ports get's deleted in meanwhile
whole transaction fails.

To handle this we need to add if_exists=True to the transaction
but for that it needs to be supported in ovsdbapp. It's fixed
in ovsdbapp with [1] but would require to bump ovsdbapp
minimal version in requirements.txt which we normally don't
do for stable branches.

So using "update_lrouter_port" instead as that have the
required option available. Before [2] that was only used
but during the switch if_exists part was missed.

[1] https://review.opendev.org/q/I56685478214aae7b6d3a2a3187297ad4eb1869a3
[2] https://review.opendev.org/c/openstack/neutron/+/762695

Closes-Bug: #2065701
Related-Bug: #2060163
Change-Id: I447990509cdea9830228d3bc92a97062cc57a472
(cherry picked from commit 5bdd0efb39)
Conflicts:
	neutron/tests/unit/fake_resources.py
This commit is contained in:
yatinkarel 2024-05-28 13:11:58 +05:30 committed by yatin
parent 75eefdbc69
commit da8f6ef4dd
4 changed files with 5 additions and 5 deletions

View File

@ -1983,7 +1983,8 @@ class OVNClient(object):
for port in ports:
lrp_name = utils.ovn_lrouter_port_name(port['id'])
options = self._gen_router_port_options(port, prov_net)
commands.append(self._nb_idl.lrp_set_options(lrp_name, **options))
commands.append(self._nb_idl.update_lrouter_port(
lrp_name, if_exists=True, **options))
self._transaction(commands, txn=txn)
def _check_network_changes_in_ha_chassis_groups(self, context, lswitch,

View File

@ -62,7 +62,6 @@ class FakeOvsdbNbOvnIdl(object):
self.get_acls_for_lswitches = mock.Mock()
self.create_lrouter = mock.Mock()
self.lrp_del = mock.Mock()
self.lrp_set_options = mock.Mock()
self.update_lrouter = mock.Mock()
self.delete_lrouter = mock.Mock()
self.add_lrouter_port = mock.Mock()

View File

@ -2484,8 +2484,8 @@ class TestOVNMechanismDriver(TestOVNMechanismDriverBase):
self.mech_driver.update_network_postcommit(fake_ctx)
lrp_name = ovn_utils.ovn_lrouter_port_name(port['port']['id'])
self.nb_ovn.lrp_set_options.assert_called_once_with(
lrp_name, **expected_opts)
self.nb_ovn.update_lrouter_port.assert_called_once_with(
lrp_name, if_exists=True, **expected_opts)
def test_update_network_need_to_frag_enabled(self):
ovn_conf.cfg.CONF.set_override('ovn_emit_need_to_frag', True,

View File

@ -1689,7 +1689,7 @@ class TestOVNL3RouterPlugin(test_mech_driver.Ml2PluginV2TestCase):
self.l3_inst._nb_ovn.add_lrouter_port.assert_called_once_with(
**fake_router_port_assert)
# Since if_exists = True it will safely return
self.l3_inst._nb_ovn.lrp_set_options(
self.l3_inst._nb_ovn.update_lrouter_port(
name='lrp-router-port-id', if_exists=True,
options=fake_router_port_assert)
# If no if_exists is provided, it is defaulted to true, so this