Merge "Clean out namespaces even if we don't delete namespaces"

This commit is contained in:
Jenkins 2014-04-09 07:20:58 +00:00 committed by Gerrit Code Review
commit 7c345f1d77
2 changed files with 7 additions and 8 deletions

View File

@ -215,8 +215,7 @@ class L3NATAgent(firewall_l3_agent.FWaaSL3AgentRpcCallback, manager.Manager):
self.removed_routers = set() self.removed_routers = set()
self.sync_progress = False self.sync_progress = False
self._delete_stale_namespaces = (self.conf.use_namespaces and self._clean_stale_namespaces = self.conf.use_namespaces
self.conf.router_delete_namespaces)
self.rpc_loop = loopingcall.FixedIntervalLoopingCall( self.rpc_loop = loopingcall.FixedIntervalLoopingCall(
self._rpc_loop) self._rpc_loop)
@ -244,7 +243,7 @@ class L3NATAgent(firewall_l3_agent.FWaaSL3AgentRpcCallback, manager.Manager):
def _cleanup_namespaces(self, routers): def _cleanup_namespaces(self, routers):
"""Destroy stale router namespaces on host when L3 agent restarts """Destroy stale router namespaces on host when L3 agent restarts
This routine is called when self._delete_stale_namespaces is True. This routine is called when self._clean_stale_namespaces is True.
The argument routers is the list of routers that are recorded in The argument routers is the list of routers that are recorded in
the database as being hosted on this node. the database as being hosted on this node.
@ -280,7 +279,7 @@ class L3NATAgent(firewall_l3_agent.FWaaSL3AgentRpcCallback, manager.Manager):
except RuntimeError: except RuntimeError:
LOG.exception(_('Failed to destroy stale router namespace ' LOG.exception(_('Failed to destroy stale router namespace '
'%s'), ns) '%s'), ns)
self._delete_stale_namespaces = False self._clean_stale_namespaces = False
def _destroy_router_namespace(self, namespace): def _destroy_router_namespace(self, namespace):
ns_ip = ip_lib.IPWrapper(self.root_helper, namespace=namespace) ns_ip = ip_lib.IPWrapper(self.root_helper, namespace=namespace)
@ -860,7 +859,7 @@ class L3NATAgent(firewall_l3_agent.FWaaSL3AgentRpcCallback, manager.Manager):
# Resync is not necessary for the cleanup of stale # Resync is not necessary for the cleanup of stale
# namespaces. # namespaces.
if self._delete_stale_namespaces: if self._clean_stale_namespaces:
self._cleanup_namespaces(routers) self._cleanup_namespaces(routers)
def after_start(self): def after_start(self):

View File

@ -998,7 +998,7 @@ class TestBasicRouterOperations(base.BaseTestCase):
self.conf.set_override('router_id', '1234') self.conf.set_override('router_id', '1234')
agent = l3_agent.L3NATAgent(HOSTNAME, self.conf) agent = l3_agent.L3NATAgent(HOSTNAME, self.conf)
self.assertEqual(['1234'], agent._router_ids()) self.assertEqual(['1234'], agent._router_ids())
self.assertFalse(agent._delete_stale_namespaces) self.assertFalse(agent._clean_stale_namespaces)
def test_process_routers_with_no_ext_net_in_conf(self): def test_process_routers_with_no_ext_net_in_conf(self):
agent = l3_agent.L3NATAgent(HOSTNAME, self.conf) agent = l3_agent.L3NATAgent(HOSTNAME, self.conf)
@ -1144,7 +1144,7 @@ class TestBasicRouterOperations(base.BaseTestCase):
agent = l3_agent.L3NATAgent(HOSTNAME, self.conf) agent = l3_agent.L3NATAgent(HOSTNAME, self.conf)
self.assertTrue(agent._delete_stale_namespaces) self.assertTrue(agent._clean_stale_namespaces)
pm = self.external_process.return_value pm = self.external_process.return_value
pm.reset_mock() pm.reset_mock()
@ -1158,7 +1158,7 @@ class TestBasicRouterOperations(base.BaseTestCase):
expected_args = [mock.call(ns) for ns in stale_namespace_list] expected_args = [mock.call(ns) for ns in stale_namespace_list]
agent._destroy_router_namespace.assert_has_calls(expected_args, agent._destroy_router_namespace.assert_has_calls(expected_args,
any_order=True) any_order=True)
self.assertFalse(agent._delete_stale_namespaces) self.assertFalse(agent._clean_stale_namespaces)
def test_cleanup_namespace(self): def test_cleanup_namespace(self):
self.conf.set_override('router_id', None) self.conf.set_override('router_id', None)