From cf96bd8bdf9751c54ba8d47569e4a1269fc61e9e Mon Sep 17 00:00:00 2001 From: Sahid Orentino Ferdjaoui Date: Mon, 6 Mar 2023 13:55:31 +0100 Subject: [PATCH] ovs: fix regression when vlan mapping is not already registered Bug introduced by Ic3c147136549b17aea0fe78e930a41a5b33ab9d8, when a VLAN mapping is not registered during a call to update_network_segement, the function should return None. Closes-Bug: #2009215 Signed-off-by: Sahid Orentino Ferdjaoui Change-Id: I91f8e8bd18d9956216e5715c658dfb408a2cbf07 --- .../ml2/drivers/openvswitch/agent/ovs_neutron_agent.py | 3 +++ .../drivers/openvswitch/agent/test_ovs_neutron_agent.py | 9 +++++++++ 2 files changed, 12 insertions(+) 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 4c14454cd83..d6d45fe3f7e 100644 --- a/neutron/plugins/ml2/drivers/openvswitch/agent/ovs_neutron_agent.py +++ b/neutron/plugins/ml2/drivers/openvswitch/agent/ovs_neutron_agent.py @@ -507,6 +507,9 @@ class OVSNeutronAgent(l2population_rpc.L2populationRpcCallBackTunnelMixin, LOG.warning("Can't update segmentation id on no uniq segment " "for a network %s", network['id']) return + except vlanmanager.MappingNotFound: + LOG.debug("Mapping not found for network %s", network['id']) + return if segmentation_id_old is None: # The segmentation id did not changed. 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 2a7532b618c..587d3c8e1c4 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 @@ -2725,6 +2725,15 @@ class TestOvsNeutronAgent(object): self.agent._update_network_segmentation_id(network) mock_get.assert_not_called() + def test__update_network_segmentation_id_mapping_not_found(self): + network = {'id': 'my-net-uuid', + 'segments': [mock.ANY]} + with mock.patch.object(self.agent.vlan_manager, + 'get') as mock_get: + mock_get.side_effect = ValueError + self.assertIsNone( + self.agent._update_network_segmentation_id(network)) + def _test_treat_smartnic_port(self, vif_type): vm_uuid = "407a79e0-e0be-4b7d-92a6-513b2161011b" iface_id = "407a79e0-e0be-4b7d-92a6-513b2161011c"