Merge "Do not delete fip namespace during l3 dvr agent resync"

This commit is contained in:
Jenkins 2015-08-09 03:49:06 +00:00 committed by Gerrit Code Review
commit 4aa8574f8d
3 changed files with 15 additions and 6 deletions

View File

@ -538,6 +538,12 @@ class L3NATAgent(firewall_l3_agent.FWaaSL3AgentRpcCallback,
LOG.debug('Processing :%r', routers)
for r in routers:
ns_manager.keep_router(r['id'])
if r.get('distributed'):
# need to keep fip namespaces as well
ext_net_id = (r['external_gateway_info'] or {}).get(
'network_id')
if ext_net_id:
ns_manager.keep_ext_net(ext_net_id)
update = queue.RouterUpdate(r['id'],
queue.PRIORITY_SYNC_ROUTERS_TASK,
router=r,

View File

@ -95,6 +95,9 @@ class NamespaceManager(object):
def keep_router(self, router_id):
self._ids_to_keep.add(router_id)
def keep_ext_net(self, ext_net_id):
self._ids_to_keep.add(ext_net_id)
def get_prefix_and_id(self, ns_name):
"""Get the prefix and id from the namespace name.

View File

@ -64,7 +64,9 @@ class TestNamespaceManager(NamespaceManagerTestCaseFramework):
self.assertTrue(self.ns_manager.is_managed(router_ns_name))
router_ns_name = dvr_snat_ns.SNAT_NS_PREFIX + router_id
self.assertTrue(self.ns_manager.is_managed(router_ns_name))
router_ns_name = dvr_fip_ns.FIP_NS_PREFIX + router_id
ext_net_id = _uuid()
router_ns_name = dvr_fip_ns.FIP_NS_PREFIX + ext_net_id
self.assertTrue(self.ns_manager.is_managed(router_ns_name))
self.assertFalse(self.ns_manager.is_managed('dhcp-' + router_id))
@ -95,14 +97,12 @@ class TestNamespaceManager(NamespaceManagerTestCaseFramework):
ns_names = [namespaces.NS_PREFIX + _uuid() for _ in range(5)]
ns_names += [dvr_snat_ns.SNAT_NS_PREFIX + _uuid() for _ in range(5)]
ns_names += [namespaces.NS_PREFIX + router_id,
dvr_snat_ns.SNAT_NS_PREFIX + router_id,
dvr_fip_ns.FIP_NS_PREFIX + router_id]
dvr_snat_ns.SNAT_NS_PREFIX + router_id]
with mock.patch.object(ip_lib.IPWrapper, 'get_namespaces',
return_value=ns_names), \
mock.patch.object(self.ns_manager, '_cleanup') as mock_cleanup:
self.ns_manager.ensure_router_cleanup(router_id)
expected = [mock.call(namespaces.NS_PREFIX, router_id),
mock.call(dvr_snat_ns.SNAT_NS_PREFIX, router_id),
mock.call(dvr_fip_ns.FIP_NS_PREFIX, router_id)]
mock.call(dvr_snat_ns.SNAT_NS_PREFIX, router_id)]
mock_cleanup.assert_has_calls(expected, any_order=True)
self.assertEqual(3, mock_cleanup.call_count)
self.assertEqual(2, mock_cleanup.call_count)