From 282eadc68f8713fdc8b6cac505e4a5e27d2a7450 Mon Sep 17 00:00:00 2001 From: Oleg Bondarev Date: Wed, 12 Dec 2018 15:11:43 +0400 Subject: [PATCH] Do state report after setting start_flag on OVS restart This fixes race condition leading to lack of fdb entries on agent after OVS restart, if agent managed to handle all ports before sending state report with start_flag set to True. Change-Id: I943f8d805630cdfbefff9cff1fb4bce89210618b Closes-Bug: #1808136 (cherry picked from commit 3995abefb16181594181133b271cdf35fa8d9937) --- .../ml2/drivers/openvswitch/agent/ovs_neutron_agent.py | 3 +++ .../drivers/openvswitch/agent/test_ovs_neutron_agent.py | 8 ++++++-- 2 files changed, 9 insertions(+), 2 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 2f950c33837..a0a1ed0373d 100644 --- a/neutron/plugins/ml2/drivers/openvswitch/agent/ovs_neutron_agent.py +++ b/neutron/plugins/ml2/drivers/openvswitch/agent/ovs_neutron_agent.py @@ -2006,6 +2006,9 @@ class OVSNeutronAgent(l2population_rpc.L2populationRpcCallBackTunnelMixin, self.setup_tunnel_br_flows() self.agent_state['start_flag'] = True tunnel_sync = True + # Force state report to avoid race condition + # with l2pop fdb entries update + self._report_state() if self.enable_distributed_routing: self.dvr_agent.reset_ovs_parameters(self.int_br, self.tun_br, 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 5f4941826aa..e4fa72e5ef9 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 @@ -1968,7 +1968,9 @@ class TestOvsNeutronAgent(object): 'setup_tunnel_br_flows') as setup_tunnel_br_flows,\ mock.patch.object( self.mod_agent.OVSNeutronAgent, - '_reset_tunnel_ofports') as reset_tunnel_ofports: + '_reset_tunnel_ofports') as reset_tunnel_ofports,\ + mock.patch.object(self.agent.state_rpc, + 'report_state') as report_st: log_exception.side_effect = Exception( 'Fake exception to get out of the loop') devices_not_ready = set() @@ -2016,7 +2018,9 @@ class TestOvsNeutronAgent(object): self.assertTrue(setup_tunnel_br_flows.called) self.assertTrue(setup_tunnel_br.called) if self.agent.enable_tunneling: - self.assertTrue(self.agent.agent_state.get('start_flag')) + self.agent.agent_state['start_flag'] = True + report_st.assert_called_once_with( + self.agent.context, self.agent.agent_state, True) def test_ovs_status(self): self._test_ovs_status(constants.OVS_NORMAL,