Merge "[OVN][Cosmetic] Improve gen_router_port_options"

This commit is contained in:
Zuul 2022-03-02 09:54:33 +00:00 committed by Gerrit Code Review
commit 6a571f8068
2 changed files with 8 additions and 6 deletions

View File

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

View File

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