Support multiple external networks in L3 agent
Change [1] removed the deprecated option external_network_bridge. Per
commit message in change [2], "l3 agent can handle any networks by
setting the neutron parameter external_network_bridge and
gateway_external_network_id to empty". So the consequence of [1] was to
introduce a regression whereby multiple external networks are not
supported by the L3 agent anymore.
This change proposes a new simplified rule. If
gateway_external_network_id is defined, that is the network that the L3
agent will use. If not and multiple external networks exist, the L3
agent will handle any of them.
[1] https://review.opendev.org/#/c/567369/
[2] https://review.opendev.org/#/c/59359
Change-Id: Idd766bd069eda85ab6876a78b8b050ee5ab66cf6
Closes-Bug: #1824571
(cherry picked from commit 0b3f5f429d
)
This commit is contained in:
parent
7cdb14a1c0
commit
62e0bee820
|
@ -36,7 +36,6 @@ from oslo_utils import excutils
|
|||
from oslo_utils import timeutils
|
||||
from osprofiler import profiler
|
||||
|
||||
from neutron._i18n import _
|
||||
from neutron.agent.common import resource_processing_queue as queue
|
||||
from neutron.agent.common import utils as common_utils
|
||||
from neutron.agent.l3 import dvr
|
||||
|
@ -368,12 +367,10 @@ class L3NATAgent(ha.AgentMixin,
|
|||
except oslo_messaging.RemoteError as e:
|
||||
with excutils.save_and_reraise_exception() as ctx:
|
||||
if e.exc_type == 'TooManyExternalNetworks':
|
||||
# At this point we know gateway_external_network_id is not
|
||||
# defined. Since there are more than one external network,
|
||||
# we will handle all of them
|
||||
ctx.reraise = False
|
||||
msg = _(
|
||||
"The 'gateway_external_network_id' option must be "
|
||||
"configured for this agent as Neutron has more than "
|
||||
"one external network.")
|
||||
raise Exception(msg)
|
||||
|
||||
def _create_router(self, router_id, router):
|
||||
args = []
|
||||
|
|
|
@ -24,7 +24,6 @@ import netaddr
|
|||
from neutron_lib.agent import constants as agent_consts
|
||||
from neutron_lib.api.definitions import portbindings
|
||||
from neutron_lib import constants as lib_constants
|
||||
from neutron_lib import exceptions as exc
|
||||
from neutron_lib.exceptions import l3 as l3_exc
|
||||
from oslo_config import cfg
|
||||
from oslo_log import log
|
||||
|
@ -2889,12 +2888,11 @@ class TestBasicRouterOperations(BasicRouterOperationsFramework):
|
|||
'external_gateway_info': {'network_id': 'aaa'}}
|
||||
|
||||
agent.router_info = {}
|
||||
self.plugin_api.get_external_network_id.side_effect = (
|
||||
exc.TooManyExternalNetworks())
|
||||
self.assertRaises(exc.TooManyExternalNetworks,
|
||||
agent._process_router_if_compatible,
|
||||
router)
|
||||
self.assertNotIn(router['id'], agent.router_info)
|
||||
e = oslo_messaging.RemoteError()
|
||||
e.exc_type = 'TooManyExternalNetworks'
|
||||
agent.plugin_rpc.get_external_network_id.side_effect = e
|
||||
agent._process_router_if_compatible(router)
|
||||
self.assertIn(router['id'], agent.router_info)
|
||||
|
||||
def test_process_router_if_compatible_with_ext_net_in_conf(self):
|
||||
agent = l3_agent.L3NATAgent(HOSTNAME, self.conf)
|
||||
|
@ -2912,19 +2910,6 @@ class TestBasicRouterOperations(BasicRouterOperationsFramework):
|
|||
router)
|
||||
self.assertNotIn(router['id'], agent.router_info)
|
||||
|
||||
def test_process_router_if_compatible_with_no_bridge_no_ext_net(self):
|
||||
agent = l3_agent.L3NATAgent(HOSTNAME, self.conf)
|
||||
self.plugin_api.get_external_network_id.return_value = 'aaa'
|
||||
|
||||
router = {'id': _uuid(),
|
||||
'routes': [],
|
||||
'admin_state_up': True,
|
||||
'external_gateway_info': {'network_id': 'aaa'}}
|
||||
|
||||
agent.router_info = {}
|
||||
agent._process_router_if_compatible(router)
|
||||
self.assertIn(router['id'], agent.router_info)
|
||||
|
||||
def test_nonexistent_interface_driver(self):
|
||||
self.conf.set_override('interface_driver', None)
|
||||
self.assertRaises(SystemExit, l3_agent.L3NATAgent,
|
||||
|
|
Loading…
Reference in New Issue