File 0004-Force-all-fdb-entries-update-after-ovs-vswitchd-rest.patch of Package openstack-neutron

From c4f6c65390b0838f19becfe0ab9d10c8550ba089 Mon Sep 17 00:00:00 2001
From: Slawek Kaplonski <skaplons@redhat.com>
Date: Wed, 28 Nov 2018 22:42:18 +0100
Subject: [PATCH 4/5] Force all fdb entries update after ovs-vswitchd restart

When ovs-vswitchd process is restarted neutron-ovs-agent will
handle it and reconfigure all ports and openflows in bridges.
Unfortunatelly when tunnel networks are used together with
L2pop mechanism driver, this driver will not notice that agent
lost all openflow config and will not send all fdb entries which
should be added on host.

In such case L2pop mechanism driver should behave in same way like
when neutron-ovs-agent is restarted and send all fdb_entries to
agent.

This patch adds "simulate" of agent start flag when ovs_restart is
handled thus neutron-server will send all fdb_entries to agent and
tunnels openflow rules can be reconfigured properly.

Change-Id: I5f1471e20bbad90c4cdcbc6c06d3a4412db55b2a
Closes-bug: #1804842
(cherry picked from commit ae031d18866a9e3652f4fc122f120915209a7b29)
(cherry picked from commit dd6a52529e483829e48e2ed62d10bb98307fd3c9)
---
 .../ml2/drivers/openvswitch/agent/ovs_neutron_agent.py      | 3 ++-
 .../ml2/drivers/openvswitch/agent/test_ovs_neutron_agent.py | 6 ++++++
 2 files changed, 8 insertions(+), 1 deletion(-)

Index: neutron-9.4.2.dev21/neutron/plugins/ml2/drivers/openvswitch/agent/ovs_neutron_agent.py
===================================================================
--- neutron-9.4.2.dev21.orig/neutron/plugins/ml2/drivers/openvswitch/agent/ovs_neutron_agent.py
+++ neutron-9.4.2.dev21/neutron/plugins/ml2/drivers/openvswitch/agent/ovs_neutron_agent.py
@@ -326,7 +326,7 @@ class OVSNeutronAgent(sg_rpc.SecurityGro
 
             # we only want to update resource versions on startup
             self.agent_state.pop('resource_versions', None)
-            if self.agent_state.pop('start_flag', None):
+            if self.agent_state.pop('start_flag', None) and self.iter_num == 0:
                 # On initial start, we notify systemd after initialization
                 # is complete.
                 systemd.notify_once()
@@ -1992,6 +1992,7 @@ class OVSNeutronAgent(sg_rpc.SecurityGro
                     self._reset_tunnel_ofports()
                     self.setup_tunnel_br()
                     self.setup_tunnel_br_flows()
+                    self.agent_state['start_flag'] = True
                     tunnel_sync = True
                 if self.enable_distributed_routing:
                     self.dvr_agent.reset_ovs_parameters(self.int_br,
Index: neutron-9.4.2.dev21/neutron/tests/unit/plugins/ml2/drivers/openvswitch/agent/test_ovs_neutron_agent.py
===================================================================
--- neutron-9.4.2.dev21.orig/neutron/tests/unit/plugins/ml2/drivers/openvswitch/agent/test_ovs_neutron_agent.py
+++ neutron-9.4.2.dev21/neutron/tests/unit/plugins/ml2/drivers/openvswitch/agent/test_ovs_neutron_agent.py
@@ -1830,6 +1830,10 @@ class TestOvsNeutronAgent(object):
                 failed_devices,
                 Exception('Fake exception to get out of the loop')]
             check_ovs_status.side_effect = args
+
+            if self.agent.enable_tunneling:
+                self.agent.agent_state.pop("start_flag")
+
             try:
                 self.agent.daemon_loop()
             except Exception:
@@ -1859,6 +1863,8 @@ class TestOvsNeutronAgent(object):
             self.assertTrue(reset_tunnel_ofports.called)
             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'))
 
     def test_ovs_status(self):
         self._test_ovs_status(constants.OVS_NORMAL,
openSUSE Build Service is sponsored by