Not process port forwarding if no snat functionality

If dvr router is processed on a 'dvr_snat' node but without snat
functionality, the port forwarding should not be processed on
this host since the snat-namespace will never be created. For
instance, the isolated DHCP node which only have the namespace
of qrouter. The l3 agent will process this router, but should
not do any port forwarding actions.

Change-Id: I6ecd86089643f4eb98865a8d8d0dec4359564026
Closes-Bug: #1825088
This commit is contained in:
LIU Yulong 2019-04-17 20:52:39 +08:00 committed by Nate Johnston
parent ad028b55ca
commit 4082e280c8
2 changed files with 20 additions and 0 deletions

View File

@ -270,6 +270,10 @@ class PortForwardingAgentExtension(l3_extension.L3AgentExtension):
constants.L3_AGENT_MODE_DVR]):
# just support centralized cases
return False
if is_distributed and not ri.snat_namespace.exists():
return False
return True
def _process_port_forwarding_event(self, context, port_forwarding,

View File

@ -280,6 +280,22 @@ class FipPortForwardingExtensionTestCase(PortForwardingExtensionBaseTestCase):
lib_const.FLOATINGIP_STATUS_DOWN}
mock_send_fip_status.assert_called_once_with(mock.ANY, fip_status)
def test_check_if_need_process_no_snat_ns(self):
ex_gw_port = {'id': _uuid()}
router_id = _uuid()
router = {'id': router_id,
'gw_port': ex_gw_port,
'ha': False,
'distributed': True}
router_info = l3router.RouterInfo(
self.agent, router_id, router,
**self.ri_kwargs)
router_info.agent_conf.agent_mode = lib_const.L3_AGENT_MODE_DVR_SNAT
router_info.fip_managed_by_port_forwardings = True
router_info.snat_namespace = mock.Mock()
router_info.snat_namespace.exists.return_value = False
self.assertFalse(self.fip_pf_ext._check_if_need_process(router_info))
class RouterFipPortForwardingMappingTestCase(base.BaseTestCase):