From 448bc8e5220d3633f9c9ee804de0a38c2d829d78 Mon Sep 17 00:00:00 2001 From: Hong Hui Xiao Date: Tue, 21 Jun 2016 08:49:42 +0000 Subject: [PATCH] Remove the deprecated config 'router_id' It was deprecated at [1]. Remove the deprecated config 'router_id' and its related tests. [1] https://review.openstack.org/#/c/248498 DocImpact: All references of 'router_id' configuration option and its description should be removed from the docs. UpgradeImpact: Remove 'router_id' configuration option from the l3_agent.ini. Change-Id: Ic9420191e8c1a333e4dcc0b70411591b8573ec7c Closes-Bug: #1594711 --- neutron/agent/l3/agent.py | 7 +-- neutron/agent/l3/config.py | 4 -- neutron/tests/common/helpers.py | 9 ++-- neutron/tests/unit/agent/l3/test_agent.py | 19 ------- .../unit/agent/l3/test_dvr_local_router.py | 1 - .../tests/unit/db/test_agentschedulers_db.py | 53 ------------------- .../remove-router_id-b3732089f8f1faa1.yaml | 10 ++++ 7 files changed, 15 insertions(+), 88 deletions(-) create mode 100644 releasenotes/notes/remove-router_id-b3732089f8f1faa1.yaml diff --git a/neutron/agent/l3/agent.py b/neutron/agent/l3/agent.py index 63954001da2..912164746c8 100644 --- a/neutron/agent/l3/agent.py +++ b/neutron/agent/l3/agent.py @@ -401,9 +401,6 @@ class L3NATAgent(ha.AgentMixin, self.conf.external_network_bridge) return - if self.conf.router_id and router['id'] != self.conf.router_id: - raise n_exc.RouterNotCompatibleWithAgent(router_id=router['id']) - # Either ex_net_id or handle_internal_only_routers must be set ex_net_id = (router['external_gateway_info'] or {}).get('network_id') if not ex_net_id and not self.conf.handle_internal_only_routers: @@ -535,8 +532,7 @@ class L3NATAgent(ha.AgentMixin, timestamp = timeutils.utcnow() try: - router_ids = ([self.conf.router_id] if self.conf.router_id else - self.plugin_rpc.get_router_ids(context)) + router_ids = self.plugin_rpc.get_router_ids(context) # fetch routers by chunks to reduce the load on server and to # start router processing earlier for i in range(0, len(router_ids), self.sync_routers_chunk_size): @@ -624,7 +620,6 @@ class L3NATAgentWithStateReport(L3NATAgent): 'topic': topics.L3_AGENT, 'configurations': { 'agent_mode': self.conf.agent_mode, - 'router_id': self.conf.router_id, 'handle_internal_only_routers': self.conf.handle_internal_only_routers, 'external_network_bridge': self.conf.external_network_bridge, diff --git a/neutron/agent/l3/config.py b/neutron/agent/l3/config.py index c54f7f61279..90b48b67bb4 100644 --- a/neutron/agent/l3/config.py +++ b/neutron/agent/l3/config.py @@ -45,10 +45,6 @@ OPTS = [ default=3, help=_("Send this many gratuitous ARPs for HA setup, if " "less than or equal to 0, the feature is disabled")), - cfg.StrOpt('router_id', default='', - deprecated_for_removal=True, - help=_("If non-empty, the l3 agent can only configure a router " - "that has the matching router ID.")), cfg.BoolOpt('handle_internal_only_routers', default=True, help=_("Indicates that this L3 agent should also handle " diff --git a/neutron/tests/common/helpers.py b/neutron/tests/common/helpers.py index 9dda3f208c6..4b49495f0e0 100644 --- a/neutron/tests/common/helpers.py +++ b/neutron/tests/common/helpers.py @@ -55,7 +55,7 @@ class FakePlugin(common_db_mixin.CommonDbMixin, def _get_l3_agent_dict(host, agent_mode, internal_only=True, - ext_net_id='', ext_bridge='', router_id=None, + ext_net_id='', ext_bridge='', az=DEFAULT_AZ): return { 'agent_type': constants.AGENT_TYPE_L3, @@ -66,8 +66,7 @@ def _get_l3_agent_dict(host, agent_mode, internal_only=True, 'configurations': {'agent_mode': agent_mode, 'handle_internal_only_routers': internal_only, 'external_network_bridge': ext_bridge, - 'gateway_external_network_id': ext_net_id, - 'router_id': router_id}} + 'gateway_external_network_id': ext_net_id}} def _register_agent(agent, plugin=None): @@ -81,9 +80,9 @@ def _register_agent(agent, plugin=None): def register_l3_agent(host=HOST, agent_mode=n_const.L3_AGENT_MODE_LEGACY, internal_only=True, ext_net_id='', ext_bridge='', - router_id=None, az=DEFAULT_AZ): + az=DEFAULT_AZ): agent = _get_l3_agent_dict(host, agent_mode, internal_only, ext_net_id, - ext_bridge, router_id, az) + ext_bridge, az) return _register_agent(agent) diff --git a/neutron/tests/unit/agent/l3/test_agent.py b/neutron/tests/unit/agent/l3/test_agent.py index 8240b656a58..b84ab465a98 100644 --- a/neutron/tests/unit/agent/l3/test_agent.py +++ b/neutron/tests/unit/agent/l3/test_agent.py @@ -1999,10 +1999,6 @@ class TestBasicRouterOperations(BasicRouterOperationsFramework): def test_disable_metadata_proxy_spawn(self): self._configure_metadata_proxy(enableflag=False) - def test_router_id_specified_in_conf(self): - self.conf.set_override('router_id', '1234') - self._configure_metadata_proxy() - def _test_process_routers_update_rpc_timeout(self, ext_net_call=False, ext_net_call_failed=False): agent = l3_agent.L3NATAgent(HOSTNAME, self.conf) @@ -2222,7 +2218,6 @@ class TestBasicRouterOperations(BasicRouterOperationsFramework): self.assertFalse(agent.namespaces_manager._clean_stale) def test_cleanup_namespace(self): - self.conf.set_override('router_id', None) stale_namespaces = [namespaces.NS_PREFIX + 'foo', namespaces.NS_PREFIX + 'bar', dvr_snat_ns.SNAT_NS_PREFIX + 'foo'] @@ -2233,7 +2228,6 @@ class TestBasicRouterOperations(BasicRouterOperationsFramework): other_namespaces) def test_cleanup_namespace_with_registered_router_ids(self): - self.conf.set_override('router_id', None) stale_namespaces = [namespaces.NS_PREFIX + 'cccc', namespaces.NS_PREFIX + 'eeeee', dvr_snat_ns.SNAT_NS_PREFIX + 'fffff'] @@ -2245,19 +2239,6 @@ class TestBasicRouterOperations(BasicRouterOperationsFramework): router_list, other_namespaces) - def test_cleanup_namespace_with_conf_router_id(self): - self.conf.set_override('router_id', 'bbbbb') - stale_namespaces = [namespaces.NS_PREFIX + 'cccc', - namespaces.NS_PREFIX + 'eeeee', - namespaces.NS_PREFIX + self.conf.router_id] - router_list = [{'id': 'foo', 'distributed': False}, - {'id': 'aaaa', 'distributed': False}] - other_namespaces = ['qdhcp-aabbcc', 'unknown'] - - self._cleanup_namespace_test(stale_namespaces, - router_list, - other_namespaces) - def test_create_dvr_gateway(self): agent = l3_agent.L3NATAgent(HOSTNAME, self.conf) router = l3_test_common.prepare_router_data() diff --git a/neutron/tests/unit/agent/l3/test_dvr_local_router.py b/neutron/tests/unit/agent/l3/test_dvr_local_router.py index 195e4cc9e7a..81793ed8252 100644 --- a/neutron/tests/unit/agent/l3/test_dvr_local_router.py +++ b/neutron/tests/unit/agent/l3/test_dvr_local_router.py @@ -55,7 +55,6 @@ class TestDvrRouterOperations(base.BaseTestCase): agent_config.register_process_monitor_opts(self.conf) self.conf.register_opts(interface.OPTS) self.conf.register_opts(external_process.OPTS) - self.conf.set_override('router_id', 'fake_id') self.conf.set_override('interface_driver', 'neutron.agent.linux.interface.NullDriver') self.conf.set_override('send_arp_for_ha', 1) diff --git a/neutron/tests/unit/db/test_agentschedulers_db.py b/neutron/tests/unit/db/test_agentschedulers_db.py index efea84046aa..2ecb0525f5c 100644 --- a/neutron/tests/unit/db/test_agentschedulers_db.py +++ b/neutron/tests/unit/db/test_agentschedulers_db.py @@ -927,23 +927,6 @@ class OvsAgentSchedulerTestCase(OvsAgentSchedulerTestCaseBase): self.assertEqual(2, num_hostb_routers) self.assertEqual(0, num_hosta_routers) - def test_router_auto_schedule_with_candidates(self): - with self.router() as router1, self.router() as router2: - l3_rpc_cb = l3_rpc.L3RpcCallback() - agent = helpers.register_l3_agent( - host=L3_HOSTA, router_id=router1['router']['id']) - l3_rpc_cb.get_router_ids(self.adminContext, host=L3_HOSTA) - hosta_routers = self._list_routers_hosted_by_l3_agent(agent.id) - num_hosta_routers = len(hosta_routers['routers']) - l3_agents_1 = self._list_l3_agents_hosting_router( - router1['router']['id']) - l3_agents_2 = self._list_l3_agents_hosting_router( - router2['router']['id']) - # L3 agent will host only the compatible router. - self.assertEqual(1, num_hosta_routers) - self.assertEqual(1, len(l3_agents_1['agents'])) - self.assertEqual(0, len(l3_agents_2['agents'])) - def test_rpc_sync_routers(self): l3_rpc_cb = l3_rpc.L3RpcCallback() self._register_agent_states() @@ -1017,42 +1000,6 @@ class OvsAgentSchedulerTestCase(OvsAgentSchedulerTestCaseBase): # Sync all routers (router3 is scheduled) _sync_router_with_ids(router_ids, 4, 4, hosta_id) - def test_router_schedule_with_candidates(self): - with self.router() as router1,\ - self.router() as router2,\ - self.subnet() as subnet1,\ - self.subnet(cidr='10.0.3.0/24') as subnet2: - agent = helpers.register_l3_agent( - host=L3_HOSTA, router_id=router1['router']['id']) - self._router_interface_action('add', - router1['router']['id'], - subnet1['subnet']['id'], - None) - self._router_interface_action('add', - router2['router']['id'], - subnet2['subnet']['id'], - None) - hosta_routers = self._list_routers_hosted_by_l3_agent(agent.id) - num_hosta_routers = len(hosta_routers['routers']) - l3_agents_1 = self._list_l3_agents_hosting_router( - router1['router']['id']) - l3_agents_2 = self._list_l3_agents_hosting_router( - router2['router']['id']) - # safe cleanup - self._router_interface_action('remove', - router1['router']['id'], - subnet1['subnet']['id'], - None) - self._router_interface_action('remove', - router2['router']['id'], - subnet2['subnet']['id'], - None) - - # L3 agent will host only the compatible router. - self.assertEqual(1, num_hosta_routers) - self.assertEqual(1, len(l3_agents_1['agents'])) - self.assertEqual(0, len(l3_agents_2['agents'])) - def test_router_without_l3_agents(self): with self.subnet() as s: self._set_net_external(s['subnet']['network_id']) diff --git a/releasenotes/notes/remove-router_id-b3732089f8f1faa1.yaml b/releasenotes/notes/remove-router_id-b3732089f8f1faa1.yaml new file mode 100644 index 00000000000..99757af0b26 --- /dev/null +++ b/releasenotes/notes/remove-router_id-b3732089f8f1faa1.yaml @@ -0,0 +1,10 @@ +--- +prelude: > + Remove 'router_id' configuration option from the + l3_agent.ini file. 'router_id' option has been defined + in order to associate an l3-agent to a specific router + when use_namespaces=False. It was deprecated after + use_namespaces was removed in Mitaka release. +upgrade: + - Remove 'router_id' configuration option from the + l3_agent.ini file.