Merge "Not process port forwarding if no snat functionality"

This commit is contained in:
Zuul 2019-04-28 10:40:55 +00:00 committed by Gerrit Code Review
commit 806abfce34
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):