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 c586dcf0568..0c368be6f82 100644 --- a/neutron/plugins/ml2/drivers/openvswitch/agent/ovs_neutron_agent.py +++ b/neutron/plugins/ml2/drivers/openvswitch/agent/ovs_neutron_agent.py @@ -315,11 +315,16 @@ class OVSNeutronAgent(sg_rpc.SecurityGroupAgentRpcCallbackMixin, 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(_LE("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 85fc9a75116..6a5704cafb6 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 @@ -1051,7 +1051,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