From 5a25548ada84747404001d70da14247da3a4b062 Mon Sep 17 00:00:00 2001 From: Brian Haley Date: Mon, 16 Jul 2018 14:36:22 -0400 Subject: [PATCH] Update _check_router_retain_needed() Change to do a direct return of _check_dvr_serviceable_ports_on_host() by moving distributed check earlier. Note: _check_dvr_serviceable_ports_on_host() can be called with subnet_ids=[] Trivialfix Change-Id: I50987858b04fb1cf57109517b82624760ce089dc --- neutron/db/l3_agentschedulers_db.py | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/neutron/db/l3_agentschedulers_db.py b/neutron/db/l3_agentschedulers_db.py index 54a74f07281..fc9bf978f4e 100644 --- a/neutron/db/l3_agentschedulers_db.py +++ b/neutron/db/l3_agentschedulers_db.py @@ -177,19 +177,15 @@ class L3AgentSchedulerDbMixin(l3agentscheduler.L3AgentSchedulerPluginBase, """Check whether a router needs to be retained on a host. Check whether there are DVR serviceable ports owned by the host of - a l3 agent. If so, then the routers should be retained. + an l3 agent. If so, then the routers should be retained. """ - if not host: + if not host or not router.get('distributed'): return False - retain_router = False - if router.get('distributed'): - plugin = directory.get_plugin(plugin_constants.L3) - subnet_ids = plugin.get_subnet_ids_on_router(context, router['id']) - if subnet_ids: - retain_router = plugin._check_dvr_serviceable_ports_on_host( - context, host, subnet_ids) - return retain_router + plugin = directory.get_plugin(plugin_constants.L3) + subnet_ids = plugin.get_subnet_ids_on_router(context, router['id']) + return plugin._check_dvr_serviceable_ports_on_host(context, host, + subnet_ids) def remove_router_from_l3_agent(self, context, agent_id, router_id): """Remove the router from l3 agent.