diff --git a/neutron/plugins/ml2/drivers/ovn/mech_driver/ovsdb/ovn_client.py b/neutron/plugins/ml2/drivers/ovn/mech_driver/ovsdb/ovn_client.py index c73cd3df3b3..b7270039722 100644 --- a/neutron/plugins/ml2/drivers/ovn/mech_driver/ovsdb/ovn_client.py +++ b/neutron/plugins/ml2/drivers/ovn/mech_driver/ovsdb/ovn_client.py @@ -1492,17 +1492,19 @@ class OVNClient(object): 'device_owner') if is_gw_port and ovn_conf.is_ovn_emit_need_to_frag_enabled(): try: - network_ids = set([port['network_id'] for port in - self._get_router_ports(admin_context, port['device_id'])]) + router_ports = self._get_router_ports(admin_context, + port['device_id']) + except l3_exc.RouterNotFound: + # Don't add any mtu info if the router no longer exists + LOG.debug("Router %s not found", port['device_id']) + else: + network_ids = {port['network_id'] for port in router_ports} for net in self._plugin.get_networks(admin_context, filters={'id': network_ids}): if net['mtu'] > network['mtu']: options[ovn_const.OVN_ROUTER_PORT_GW_MTU_OPTION] = str( network['mtu']) break - except l3_exc.RouterNotFound: - # Don't add any mtu info if the router no longer exists - pass return options def _create_lrouter_port(self, context, router, port, txn=None): diff --git a/neutron/tests/unit/services/ovn_l3/test_plugin.py b/neutron/tests/unit/services/ovn_l3/test_plugin.py index c4c12f081dd..448a5219dd4 100644 --- a/neutron/tests/unit/services/ovn_l3/test_plugin.py +++ b/neutron/tests/unit/services/ovn_l3/test_plugin.py @@ -1634,7 +1634,7 @@ class TestOVNL3RouterPlugin(test_mech_driver.Ml2PluginV2TestCase): 'network_id': 'priv-net'} ari.return_value = self.fake_router_interface_info # If we remove the router halfway the return value of - # _get_routers_ports will be [] + # _get_routers_ports will be RouterNotFound grps.side_effect = l3_exc.RouterNotFound(router_id=router_id) self.get_router.return_value = self.fake_router_with_ext_gw network_attrs = {'id': 'prov-net', 'mtu': 1200}