Browse Source

Initialize phys bridges before setup_rpc

Neutron-ovs-agent configures physical bridges that they works
in fail_mode=secure. This means that only packets which match some
OpenFlow rule in the bridge can be processed.
This may cause problem on hosts with only one physical NIC
where same bridge is used to provide control plane connectivity
like connection to rabbitmq and data plane connectivity for VM.
After e.g. host reboot bridge will still be in fail_mode=secure
but there will be no any OpenFlow rule on it thus there will be
no communication to rabbitmq.

With current order of actions in __init__ method of OVSNeutronAgent
class it first tries to establish connection to rabbitmq and later
configure physical bridges with some initial OpenFlow rules.
And in case described above it will fail as there is no connectivity
to rabbitmq through physical bridge.

So this patch changes order of actions in __init__ method that it first
setup physical bridges and than configure rpc connection.

Conflicts:
    neutron/plugins/ml2/drivers/openvswitch/agent/ovs_neutron_agent.py

Change-Id: I41c02b0164537c5b1c766feab8117cc88487bc77
Closes-Bug: #1840443
(cherry picked from commit d41bd58f31)
(cherry picked from commit 3a2842bdd8)
changes/55/677055/1
Slawek Kaplonski 1 month ago
parent
commit
f9473566d5

+ 2
- 1
neutron/plugins/ml2/drivers/openvswitch/agent/ovs_neutron_agent.py View File

@@ -184,7 +184,6 @@ class OVSNeutronAgent(l2population_rpc.L2populationRpcCallBackTunnelMixin,
184 184
         self.network_ports = collections.defaultdict(set)
185 185
         # keeps association between ports and ofports to detect ofport change
186 186
         self.vifname_to_ofport_map = {}
187
-        self.setup_rpc()
188 187
         # Stores newly created bridges
189 188
         self.added_bridges = list()
190 189
         self.bridge_mappings = self._parse_bridge_mappings(
@@ -218,6 +217,8 @@ class OVSNeutronAgent(l2population_rpc.L2populationRpcCallBackTunnelMixin,
218 217
             self.setup_tunnel_br(ovs_conf.tunnel_bridge)
219 218
             self.setup_tunnel_br_flows()
220 219
 
220
+        self.setup_rpc()
221
+
221 222
         agent_api = ovs_ext_api.OVSAgentExtensionAPI(self.int_br, self.tun_br)
222 223
         self.ext_manager.initialize(
223 224
             self.connection, constants.EXTENSION_DRIVER_TYPE, agent_api)

+ 14
- 0
neutron/tests/unit/plugins/ml2/drivers/openvswitch/agent/test_ovs_neutron_agent.py View File

@@ -177,6 +177,20 @@ class TestOvsNeutronAgent(object):
177 177
                 "Port", mock.ANY, "other_config", vlan_mapping)
178 178
             self.assertTrue(needs_binding)
179 179
 
180
+    def test_setup_physical_bridges_during_agent_initialization(self):
181
+        with mock.patch.object(
182
+            self.mod_agent.OVSNeutronAgent,
183
+            'setup_physical_bridges') as setup_physical_bridges,\
184
+                mock.patch.object(
185
+                    self.mod_agent.OVSNeutronAgent, 'setup_rpc') as setup_rpc:
186
+            setup_rpc.side_effect = oslo_messaging.MessagingException(
187
+                "Test communication failure")
188
+            try:
189
+                self._make_agent()
190
+            except oslo_messaging.MessagingException:
191
+                pass
192
+            setup_physical_bridges.assert_called_once_with(mock.ANY)
193
+
180 194
     def test_datapath_type_system(self):
181 195
         # verify kernel datapath is default
182 196
         expected = constants.OVS_DATAPATH_SYSTEM

Loading…
Cancel
Save