From 55afd9bc923f55bc8f621316a080ad4271182ebc Mon Sep 17 00:00:00 2001 From: Rodolfo Alonso Hernandez Date: Thu, 23 Dec 2021 11:00:09 +0000 Subject: [PATCH] [OVN] Allow only one physical network per bridge Same as in other ML2 plugins (OVS, Linux Bridge), OVN mechanism driver should allow only one physical network per bridge. The rule "one network, one bridge" should be present in OVN too. By allowing only one physical network per bridge, Neutron prevents having two networks with subnets with the same CIDR in the same bridge. Currently is possible and this CIDR clash is not prevented (shouldn't be by the API). This architectural limitation prevents this situation. This limitation is already present in deployment tools as TripleO. Closes-Bug: #1956476 Change-Id: I74a2ca9a344a93219deb94d60247478ee3200659 --- .../ml2/drivers/ovn/mech_driver/ovsdb/impl_idl_ovn.py | 3 +-- .../drivers/ovn/mech_driver/ovsdb/ovsdb_monitor.py | 3 +-- .../drivers/ovn/mech_driver/ovsdb/test_impl_idl.py | 11 ++++++++++- ...limit-one-physnet-per-bridge-188285955a5ea124.yaml | 4 ++++ 4 files changed, 16 insertions(+), 5 deletions(-) create mode 100644 releasenotes/notes/ovn-limit-one-physnet-per-bridge-188285955a5ea124.yaml diff --git a/neutron/plugins/ml2/drivers/ovn/mech_driver/ovsdb/impl_idl_ovn.py b/neutron/plugins/ml2/drivers/ovn/mech_driver/ovsdb/impl_idl_ovn.py index 26c821a9ad8..2d7a4b2cdd1 100644 --- a/neutron/plugins/ml2/drivers/ovn/mech_driver/ovsdb/impl_idl_ovn.py +++ b/neutron/plugins/ml2/drivers/ovn/mech_driver/ovsdb/impl_idl_ovn.py @@ -828,8 +828,7 @@ class OvsdbSbOvnIdl(sb_impl_idl.OvnSbApiIdlImpl, Backend): def _get_chassis_physnets(self, chassis): bridge_mappings = chassis.external_ids.get('ovn-bridge-mappings', '') - mapping_dict = helpers.parse_mappings(bridge_mappings.split(','), - unique_values=False) + mapping_dict = helpers.parse_mappings(bridge_mappings.split(',')) return list(mapping_dict.keys()) def chassis_exists(self, hostname): diff --git a/neutron/plugins/ml2/drivers/ovn/mech_driver/ovsdb/ovsdb_monitor.py b/neutron/plugins/ml2/drivers/ovn/mech_driver/ovsdb/ovsdb_monitor.py index 69ba3ababbd..96fe9e69445 100644 --- a/neutron/plugins/ml2/drivers/ovn/mech_driver/ovsdb/ovsdb_monitor.py +++ b/neutron/plugins/ml2/drivers/ovn/mech_driver/ovsdb/ovsdb_monitor.py @@ -194,8 +194,7 @@ class ChassisEvent(row_event.RowEvent): phy_nets = [] if event != self.ROW_DELETE: bridge_mappings = row.external_ids.get('ovn-bridge-mappings', '') - mapping_dict = helpers.parse_mappings(bridge_mappings.split(','), - unique_values=False) + mapping_dict = helpers.parse_mappings(bridge_mappings.split(',')) phy_nets = list(mapping_dict) self.driver.update_segment_host_mapping(host, phy_nets) diff --git a/neutron/tests/functional/plugins/ml2/drivers/ovn/mech_driver/ovsdb/test_impl_idl.py b/neutron/tests/functional/plugins/ml2/drivers/ovn/mech_driver/ovsdb/test_impl_idl.py index 0a1cc8879b6..5f174f35a9b 100644 --- a/neutron/tests/functional/plugins/ml2/drivers/ovn/mech_driver/ovsdb/test_impl_idl.py +++ b/neutron/tests/functional/plugins/ml2/drivers/ovn/mech_driver/ovsdb/test_impl_idl.py @@ -53,7 +53,7 @@ class TestSbApi(BaseOvnIdlTest): {'external_ids': {'ovn-bridge-mappings': 'public:br-ex,private:br-0'}}, {'external_ids': {'ovn-bridge-mappings': - 'public:br-ex,public2:br-ex'}}, + 'public:br-ex,public2:br-ex2'}}, {'external_ids': {'ovn-bridge-mappings': 'public:br-ex'}}, ] @@ -99,6 +99,15 @@ class TestSbApi(BaseOvnIdlTest): self.assertGreaterEqual(set(mapping.keys()), {c['name'] for c in self.data['chassis']}) + def test_multiple_physnets_in_one_bridge(self): + self.data = { + 'chassis': [ + {'external_ids': {'ovn-bridge-mappings': 'p1:br-ex,p2:br-ex'}} + ] + } + self.load_test_data() + self.assertRaises(ValueError, self.api.get_chassis_and_physnets) + def _add_switch_port(self, chassis_name, type=ovn_const.LSP_TYPE_LOCALPORT): sname, pname = (utils.get_rand_device_name(prefix=p) diff --git a/releasenotes/notes/ovn-limit-one-physnet-per-bridge-188285955a5ea124.yaml b/releasenotes/notes/ovn-limit-one-physnet-per-bridge-188285955a5ea124.yaml new file mode 100644 index 00000000000..fcb0ca76204 --- /dev/null +++ b/releasenotes/notes/ovn-limit-one-physnet-per-bridge-188285955a5ea124.yaml @@ -0,0 +1,4 @@ +--- +other: + - | + OVN mechanism driver allows only to have one physical network per bridge.