From bd0e8af34ceb247273eb666681051228e458b954 Mon Sep 17 00:00:00 2001 From: Cedric Brandily Date: Tue, 20 Oct 2015 23:03:39 +0200 Subject: [PATCH] Remove deprecated namespace deletion options dhcp/router_delete_namespaces[1] options have been defined as a workaround to an iproute2 limitation[1] corrected 2 years ago. That's why the change removes these options after their deprecation in Liberty. [1] in neutron.agent.dhcp/l3.config DocImpact Closes-Bug: #1508189 Related-Bug: #1418079 Change-Id: I2a879213c3b095a007a4531f430a33cea9fdf1bd --- etc/dhcp_agent.ini | 10 ---------- etc/l3_agent.ini | 11 ----------- neutron/agent/dhcp/config.py | 5 ----- neutron/agent/l3/config.py | 5 ----- neutron/agent/l3/namespaces.py | 11 +++++------ neutron/agent/linux/dhcp.py | 2 +- .../agent/l3/test_namespace_manager.py | 1 - neutron/tests/unit/agent/l3/test_agent.py | 11 +---------- .../tests/unit/agent/l3/test_dvr_fip_ns.py | 7 ++++--- neutron/tests/unit/agent/linux/test_dhcp.py | 19 ------------------- 10 files changed, 11 insertions(+), 71 deletions(-) diff --git a/etc/dhcp_agent.ini b/etc/dhcp_agent.ini index 40c6c47e502..a7e5547ba31 100644 --- a/etc/dhcp_agent.ini +++ b/etc/dhcp_agent.ini @@ -91,16 +91,6 @@ # Use broadcast in DHCP replies # dhcp_broadcast_reply = False -# dhcp_delete_namespaces, which is True by default, can be set to False if -# namespaces can't be deleted cleanly on the host running the DHCP agent. -# Disable this if you hit the issue in -# https://bugs.launchpad.net/neutron/+bug/1052535 or if -# you are sure that your version of iproute suffers from the problem. -# This should not be a problem any more. Refer to bug: -# https://bugs.launchpad.net/neutron/+bug/1418079 -# This option is deprecated and will be removed in the M release -# dhcp_delete_namespaces = True - # Timeout for ovs-vsctl commands. # If the timeout expires, ovs commands will fail with ALARMCLOCK error. # ovs_vsctl_timeout = 10 diff --git a/etc/l3_agent.ini b/etc/l3_agent.ini index a0c9de71e6c..ce740a1b9d3 100644 --- a/etc/l3_agent.ini +++ b/etc/l3_agent.ini @@ -91,17 +91,6 @@ # Iptables mangle mark used to mark ingress from external network # external_ingress_mark = 0x2 -# router_delete_namespaces, which is True by default, can be set to False if -# namespaces can't be deleted cleanly on the host running the L3 agent. -# Disable this if you hit the issue in -# https://bugs.launchpad.net/neutron/+bug/1052535 or if -# you are sure that your version of iproute suffers from the problem. -# If True, namespaces will be deleted when a router is destroyed. -# This should not be a problem any more. Refer to bug: -# https://bugs.launchpad.net/neutron/+bug/1418079 -# This option is deprecated and will be removed in the M release -# router_delete_namespaces = True - # Timeout for ovs-vsctl commands. # If the timeout expires, ovs commands will fail with ALARMCLOCK error. # ovs_vsctl_timeout = 10 diff --git a/neutron/agent/dhcp/config.py b/neutron/agent/dhcp/config.py index 1ff185d83f1..a6c00b9e17f 100644 --- a/neutron/agent/dhcp/config.py +++ b/neutron/agent/dhcp/config.py @@ -55,11 +55,6 @@ DNSMASQ_OPTS = [ help=_('Comma-separated list of the DNS servers which will be ' 'used as forwarders.'), deprecated_name='dnsmasq_dns_server'), - cfg.BoolOpt('dhcp_delete_namespaces', default=True, - help=_("Delete namespace after removing a dhcp server." - "This option is deprecated and " - "will be removed in a future release."), - deprecated_for_removal=True), cfg.StrOpt('dnsmasq_base_log_dir', help=_("Base log dir for dnsmasq logging. " "The log contains DHCP and DNS log information and " diff --git a/neutron/agent/l3/config.py b/neutron/agent/l3/config.py index ce0def6453b..73e552a1a70 100644 --- a/neutron/agent/l3/config.py +++ b/neutron/agent/l3/config.py @@ -85,11 +85,6 @@ OPTS = [ 'source.')), cfg.BoolOpt('enable_metadata_proxy', default=True, help=_("Allow running metadata proxy.")), - cfg.BoolOpt('router_delete_namespaces', default=True, - help=_("Delete namespace after removing a router." - "This option is deprecated and " - "will be removed in a future release."), - deprecated_for_removal=True), cfg.StrOpt('metadata_access_mark', default='0x1', help=_('Iptables mangle mark used to mark metadata valid ' diff --git a/neutron/agent/l3/namespaces.py b/neutron/agent/l3/namespaces.py index 1f85fc149d3..e3c6973d7f6 100644 --- a/neutron/agent/l3/namespaces.py +++ b/neutron/agent/l3/namespaces.py @@ -76,12 +76,11 @@ class Namespace(object): ip_wrapper.netns.execute(cmd) def delete(self): - if self.agent_conf.router_delete_namespaces: - try: - self.ip_wrapper_root.netns.delete(self.name) - except RuntimeError: - msg = _LE('Failed trying to delete namespace: %s') - LOG.exception(msg, self.name) + try: + self.ip_wrapper_root.netns.delete(self.name) + except RuntimeError: + msg = _LE('Failed trying to delete namespace: %s') + LOG.exception(msg, self.name) class RouterNamespace(Namespace): diff --git a/neutron/agent/linux/dhcp.py b/neutron/agent/linux/dhcp.py index 2f3c87b6dd1..7c67f18d6d4 100644 --- a/neutron/agent/linux/dhcp.py +++ b/neutron/agent/linux/dhcp.py @@ -228,7 +228,7 @@ class DhcpLocalProcess(DhcpBase): LOG.warning(_LW('Failed trying to delete interface: %s'), self.interface_name) - if self.conf.dhcp_delete_namespaces and self.network.namespace: + if self.network.namespace: ns_ip = ip_lib.IPWrapper(namespace=self.network.namespace) try: ns_ip.netns.delete(self.network.namespace) diff --git a/neutron/tests/functional/agent/l3/test_namespace_manager.py b/neutron/tests/functional/agent/l3/test_namespace_manager.py index 9b58cae7804..6f070c2ab27 100644 --- a/neutron/tests/functional/agent/l3/test_namespace_manager.py +++ b/neutron/tests/functional/agent/l3/test_namespace_manager.py @@ -30,7 +30,6 @@ class NamespaceManagerTestFramework(base.BaseSudoTestCase): def setUp(self): super(NamespaceManagerTestFramework, self).setUp() self.agent_conf = mock.MagicMock() - self.agent_conf.router_delete_namespaces = True self.metadata_driver_mock = mock.Mock() self.namespace_manager = namespace_manager.NamespaceManager( self.agent_conf, driver=None, clean_stale=True, diff --git a/neutron/tests/unit/agent/l3/test_agent.py b/neutron/tests/unit/agent/l3/test_agent.py index d16a7c4c8ea..fa8730af71a 100644 --- a/neutron/tests/unit/agent/l3/test_agent.py +++ b/neutron/tests/unit/agent/l3/test_agent.py @@ -1718,16 +1718,7 @@ class TestBasicRouterOperations(BasicRouterOperationsFramework): '-bar') self.mock_ip.del_veth.assert_called_once_with('rfp-aaaa') - def test_destroy_router_namespace_skips_ns_removal(self): - self.conf.set_override('router_delete_namespaces', False) - agent = l3_agent.L3NATAgent(HOSTNAME, self.conf) - ns = namespaces.Namespace( - 'qrouter-bar', self.conf, agent.driver, agent.use_ipv6) - ns.create() - ns.delete() - self.assertEqual(0, self.mock_ip.netns.delete.call_count) - - def test_destroy_router_namespace_removes_ns(self): + def test_destroy_router_namespace(self): agent = l3_agent.L3NATAgent(HOSTNAME, self.conf) ns = namespaces.Namespace( 'qrouter-bar', self.conf, agent.driver, agent.use_ipv6) diff --git a/neutron/tests/unit/agent/l3/test_dvr_fip_ns.py b/neutron/tests/unit/agent/l3/test_dvr_fip_ns.py index a87aa31243d..49936f165bc 100644 --- a/neutron/tests/unit/agent/l3/test_dvr_fip_ns.py +++ b/neutron/tests/unit/agent/l3/test_dvr_fip_ns.py @@ -103,9 +103,10 @@ class TestDvrFipNs(base.BaseTestCase): dev2.name = 'fg-aaaa' ip_wrapper.get_devices.return_value = [dev1, dev2] - self.conf.router_delete_namespaces = False - - self.fip_ns.delete() + with mock.patch.object(self.fip_ns.ip_wrapper_root.netns, + 'delete') as delete: + self.fip_ns.delete() + delete.assert_called_once_with(mock.ANY) ext_net_bridge = self.conf.external_network_bridge ns_name = self.fip_ns.get_name() diff --git a/neutron/tests/unit/agent/linux/test_dhcp.py b/neutron/tests/unit/agent/linux/test_dhcp.py index 3f29ca60c38..ac264c30818 100644 --- a/neutron/tests/unit/agent/linux/test_dhcp.py +++ b/neutron/tests/unit/agent/linux/test_dhcp.py @@ -942,25 +942,6 @@ class TestDhcpLocalProcess(TestBase): self._assert_disabled(lp) def test_disable(self): - self.conf.set_override('dhcp_delete_namespaces', False) - attrs_to_mock = dict([(a, mock.DEFAULT) for a in - ['active', 'interface_name']]) - network = FakeDualNetwork() - with mock.patch.multiple(LocalChild, **attrs_to_mock) as mocks: - mocks['active'].__get__ = mock.Mock(return_value=True) - mocks['interface_name'].__get__ = mock.Mock(return_value='tap0') - lp = LocalChild(self.conf, network) - with mock.patch('neutron.agent.linux.ip_lib.IPWrapper') as ip: - lp.disable() - - self._assert_disabled(lp) - - self.mock_mgr.assert_has_calls([mock.call(self.conf, None), - mock.call().destroy(network, 'tap0')]) - - self.assertEqual(ip.return_value.netns.delete.call_count, 0) - - def test_disable_delete_ns(self): attrs_to_mock = {'active': mock.DEFAULT} with mock.patch.multiple(LocalChild, **attrs_to_mock) as mocks: