Merge "DVR: Don't clean snat-ns of DVR HA router when fullsync" into stable/newton

This commit is contained in:
Jenkins 2017-05-05 23:49:51 +00:00 committed by Gerrit Code Review
commit 85c9daea13
2 changed files with 24 additions and 1 deletions

View File

@ -578,7 +578,7 @@ class L3NATAgent(ha.AgentMixin,
lib_const.L3_AGENT_MODE_DVR_SNAT)
if ext_net_id:
ns_manager.keep_ext_net(ext_net_id)
elif is_snat_agent:
elif is_snat_agent and not r.get('ha'):
ns_manager.ensure_snat_cleanup(r['id'])
# For HA routers check that DB state matches actual state
if r.get('ha'):

View File

@ -37,6 +37,7 @@ from neutron.agent.l3 import dvr_snat_ns
from neutron.agent.l3 import ha
from neutron.agent.l3 import legacy_router
from neutron.agent.l3 import link_local_allocator as lla
from neutron.agent.l3 import namespace_manager
from neutron.agent.l3 import namespaces
from neutron.agent.l3 import router_info as l3router
from neutron.agent.l3 import router_processing_queue
@ -298,6 +299,28 @@ class TestBasicRouterOperations(BasicRouterOperationsFramework):
agent.periodic_sync_routers_task(agent.context)
self.assertFalse(agent.namespaces_manager._clean_stale)
def test_periodic_sync_routers_task_call_ensure_snat_cleanup(self):
agent = l3_agent.L3NATAgent(HOSTNAME, self.conf)
agent.conf.agent_mode = 'dvr_snat'
dvr_ha_router = {'id': _uuid(),
'external_gateway_info': {},
'routes': [],
'distributed': True,
'ha': True}
dvr_router = {'id': _uuid(),
'external_gateway_info': {},
'routes': [],
'distributed': True,
'ha': False}
routers = [dvr_router, dvr_ha_router]
self.plugin_api.get_router_ids.return_value = [r['id'] for r
in routers]
self.plugin_api.get_routers.return_value = routers
with mock.patch.object(namespace_manager.NamespaceManager,
'ensure_snat_cleanup') as ensure_snat_cleanup:
agent.periodic_sync_routers_task(agent.context)
ensure_snat_cleanup.assert_called_once_with(dvr_router['id'])
def test_periodic_sync_routers_task_call_clean_stale_meta_proxies(self):
agent = l3_agent.L3NATAgent(HOSTNAME, self.conf)
stale_router_ids = [_uuid(), _uuid()]