From 3a2842bdd8d8d59e445393c7c7e7a9793357df08 Mon Sep 17 00:00:00 2001 From: Slawek Kaplonski Date: Fri, 16 Aug 2019 13:44:09 +0000 Subject: [PATCH] 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. Change-Id: I41c02b0164537c5b1c766feab8117cc88487bc77 Closes-Bug: #1840443 (cherry picked from commit d41bd58f31e259fe408c8c059b31299fdfe81127) --- .../drivers/openvswitch/agent/ovs_neutron_agent.py | 3 ++- .../openvswitch/agent/test_ovs_neutron_agent.py | 14 ++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) 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 45605db2088..dd7d3b67d73 100644 --- a/neutron/plugins/ml2/drivers/openvswitch/agent/ovs_neutron_agent.py +++ b/neutron/plugins/ml2/drivers/openvswitch/agent/ovs_neutron_agent.py @@ -186,7 +186,6 @@ class OVSNeutronAgent(l2population_rpc.L2populationRpcCallBackTunnelMixin, self.network_ports = collections.defaultdict(set) # keeps association between ports and ofports to detect ofport change self.vifname_to_ofport_map = {} - self.setup_rpc() # Stores newly created bridges self.added_bridges = list() self.bridge_mappings = self._parse_bridge_mappings( @@ -229,6 +228,8 @@ class OVSNeutronAgent(l2population_rpc.L2populationRpcCallBackTunnelMixin, self.setup_tunnel_br(ovs_conf.tunnel_bridge) self.setup_tunnel_br_flows() + self.setup_rpc() + self.dvr_agent = ovs_dvr_neutron_agent.OVSDVRNeutronAgent( self.context, self.dvr_plugin_rpc, 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 20976b67b0a..9d831d9a63f 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 @@ -180,6 +180,20 @@ class TestOvsNeutronAgent(object): "Port", mock.ANY, "other_config", vlan_mapping) self.assertTrue(needs_binding) + def test_setup_physical_bridges_during_agent_initialization(self): + with mock.patch.object( + self.mod_agent.OVSNeutronAgent, + 'setup_physical_bridges') as setup_physical_bridges,\ + mock.patch.object( + self.mod_agent.OVSNeutronAgent, 'setup_rpc') as setup_rpc: + setup_rpc.side_effect = oslo_messaging.MessagingException( + "Test communication failure") + try: + self._make_agent() + except oslo_messaging.MessagingException: + pass + setup_physical_bridges.assert_called_once_with(mock.ANY) + def test_datapath_type_system(self): # verify kernel datapath is default expected = constants.OVS_DATAPATH_SYSTEM