Skip to content

Commit ece6a9a

Browse files
committed
[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 5bdd0ef) Conflicts: neutron/tests/unit/fake_resources.py
1 parent 27a543a commit ece6a9a

File tree

4 files changed

+5
-5
lines changed

4 files changed

+5
-5
lines changed

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2093,7 +2093,8 @@ def set_gateway_mtu(self, context, prov_net, txn=None):
20932093
for port in ports:
20942094
lrp_name = utils.ovn_lrouter_port_name(port['id'])
20952095
options = self._gen_router_port_options(port, prov_net)
2096-
commands.append(self._nb_idl.lrp_set_options(lrp_name, **options))
2096+
commands.append(self._nb_idl.update_lrouter_port(
2097+
lrp_name, if_exists=True, **options))
20972098
self._transaction(commands, txn=txn)
20982099

20992100
def update_network(self, context, network, original_network=None):

neutron/tests/unit/fake_resources.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,6 @@ def __init__(self, **kwargs):
6262
self.get_acls_for_lswitches = mock.Mock()
6363
self.create_lrouter = mock.Mock()
6464
self.lrp_del = mock.Mock()
65-
self.lrp_set_options = mock.Mock()
6665
self.update_lrouter = mock.Mock()
6766
self.delete_lrouter = mock.Mock()
6867
self.add_lrouter_port = mock.Mock()

neutron/tests/unit/plugins/ml2/drivers/ovn/mech_driver/test_mech_driver.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2446,8 +2446,8 @@ def _test_update_network_fragmentation(self, new_mtu, expected_opts, grps):
24462446
self.mech_driver.update_network_postcommit(fake_ctx)
24472447

24482448
lrp_name = ovn_utils.ovn_lrouter_port_name(port['port']['id'])
2449-
self.nb_ovn.lrp_set_options.assert_called_once_with(
2450-
lrp_name, **expected_opts)
2449+
self.nb_ovn.update_lrouter_port.assert_called_once_with(
2450+
lrp_name, if_exists=True, **expected_opts)
24512451

24522452
def test_update_network_need_to_frag_enabled(self):
24532453
ovn_conf.cfg.CONF.set_override('ovn_emit_need_to_frag', True,

neutron/tests/unit/services/ovn_l3/test_plugin.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1678,7 +1678,7 @@ def test_add_router_interface_need_to_frag_enabled_then_remove(
16781678
self.l3_inst._nb_ovn.add_lrouter_port.assert_called_once_with(
16791679
**fake_router_port_assert)
16801680
# Since if_exists = True it will safely return
1681-
self.l3_inst._nb_ovn.lrp_set_options(
1681+
self.l3_inst._nb_ovn.update_lrouter_port(
16821682
name='lrp-router-port-id', if_exists=True,
16831683
options=fake_router_port_assert)
16841684
# If no if_exists is provided, it is defaulted to true, so this

0 commit comments

Comments
 (0)