From 6b9d8bf3087a8fea2a991d392b314706039191a3 Mon Sep 17 00:00:00 2001 From: Oleg Bondarev Date: Mon, 4 Feb 2019 14:58:27 +0400 Subject: [PATCH] OVS agent: always send start flag during initial sync In order to avoid inaccurate agent_boot_time setting, this patch suggests to consider agent as "started" only after completion of initial sync with server. Change-Id: Icba05288889219e8a606c3809efd88b2c234bef3 Closes-Bug: #1799178 (cherry picked from commit 8f20963c5b9e6762b6322f686bce99871bec6be9) --- .../ml2/drivers/openvswitch/agent/ovs_neutron_agent.py | 9 +++++++-- .../drivers/openvswitch/agent/test_ovs_neutron_agent.py | 3 ++- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/neutron/plugins/ml2/drivers/openvswitch/agent/ovs_neutron_agent.py b/neutron/plugins/ml2/drivers/openvswitch/agent/ovs_neutron_agent.py index 14806ac545f..c30356905aa 100644 --- a/neutron/plugins/ml2/drivers/openvswitch/agent/ovs_neutron_agent.py +++ b/neutron/plugins/ml2/drivers/openvswitch/agent/ovs_neutron_agent.py @@ -329,11 +329,16 @@ class OVSNeutronAgent(l2population_rpc.L2populationRpcCallBackTunnelMixin, self.fullsync = True # we only want to update resource versions on startup - self.agent_state.pop('resource_versions', None) - if self.agent_state.pop('start_flag', None) and self.iter_num == 0: + if self.agent_state.pop('resource_versions', None): # On initial start, we notify systemd after initialization # is complete. systemd.notify_once() + + if self.iter_num > 0: + # agent is considered started after + # initial sync with server (iter 0) is done + self.agent_state.pop('start_flag', None) + except Exception: LOG.exception("Failed reporting state!") diff --git a/neutron/tests/unit/plugins/ml2/drivers/openvswitch/agent/test_ovs_neutron_agent.py b/neutron/tests/unit/plugins/ml2/drivers/openvswitch/agent/test_ovs_neutron_agent.py index 62f567538ff..03ee744dd0b 100644 --- a/neutron/tests/unit/plugins/ml2/drivers/openvswitch/agent/test_ovs_neutron_agent.py +++ b/neutron/tests/unit/plugins/ml2/drivers/openvswitch/agent/test_ovs_neutron_agent.py @@ -1137,7 +1137,8 @@ class TestOvsNeutronAgent(object): self.agent.agent_state, True) self.systemd_notify.assert_called_once_with() self.systemd_notify.reset_mock() - self.assertNotIn("start_flag", self.agent.agent_state) + # agent keeps sending "start_flag" while iter 0 not completed + self.assertIn("start_flag", self.agent.agent_state) self.assertEqual( self.agent.agent_state["configurations"]["devices"], self.agent.int_br_device_count