Do not delete fip namespace during l3 dvr agent resync

This was introduced by commit 46608806aa
which didn't take into account that fip namespace name is composed
from external network id rather than router id.
The fix is to ensure fip namespaces for the known routers are kept
by namespace manager on agent resync.

Closes-Bug: #1482521
Change-Id: I0ffd0a3f6d83f7356638827a1cfe4dabef24b891
This commit is contained in:
Oleg Bondarev 2015-08-07 19:56:13 +03:00
parent e0999554a4
commit b220d10125
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)