From 66e4a89ba19ce3293e25795f7478fd7c79a61558 Mon Sep 17 00:00:00 2001 From: Brian Haley Date: Fri, 6 Apr 2018 14:15:25 -0400 Subject: [PATCH] Read ha_state file only once check_ha_state_for_router() can potentially read the ha_state file three times, since ha_state is a defined as a property in the HaRouter() class. Read ha_state into a local variable and use it instead. Change-Id: Icabe0baf961abe4ddd0699716f26dc96696eb8b1 --- neutron/agent/l3/ha.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/neutron/agent/l3/ha.py b/neutron/agent/l3/ha.py index 69a4b056153..62f18e34a18 100644 --- a/neutron/agent/l3/ha.py +++ b/neutron/agent/l3/ha.py @@ -93,11 +93,14 @@ class AgentMixin(object): def check_ha_state_for_router(self, router_id, current_state): ri = self._get_router_info(router_id) - if ri and current_state != TRANSLATION_MAP[ri.ha_state]: + if not ri: + return + ha_state = ri.ha_state + if current_state != TRANSLATION_MAP[ha_state]: LOG.debug("Updating server with state %(state)s for router " "%(router_id)s", {'router_id': router_id, - 'state': ri.ha_state}) - self.state_change_notifier.queue_event((router_id, ri.ha_state)) + 'state': ha_state}) + self.state_change_notifier.queue_event((router_id, ha_state)) def _start_keepalived_notifications_server(self): state_change_server = (