From 796f3a60807bad3185115de5fe3ad77deea52e71 Mon Sep 17 00:00:00 2001 From: Rodolfo Alonso Hernandez Date: Tue, 22 Oct 2024 14:15:13 +0000 Subject: [PATCH] Skip LSP host info update for trunk subports In ML2/OVN, the subports bindings are not updated with the host information. This patch skips the LSP update in that case. Currently the method ``update_lsp_host_info`` is stuck executing ``_wait_for_port_bindings_host``. During this time the subport can be deleted or removed from the trunk. That will clash with the newer operation that tries to remove the LSP port host info and is the cause of the related bug. Closes-Bug: #2085462 Change-Id: Ic68f9b5aa3b06bc4e1cbfbe577efc33b4b617b45 (cherry picked from commit 63d14a3ff225faa75a825991cf0b33b2fd745b9b) --- .../ml2/drivers/ovn/mech_driver/ovsdb/ovn_client.py | 5 +++++ .../drivers/ovn/mech_driver/ovsdb/test_ovn_client.py | 10 ++++++++++ 2 files changed, 15 insertions(+) diff --git a/neutron/plugins/ml2/drivers/ovn/mech_driver/ovsdb/ovn_client.py b/neutron/plugins/ml2/drivers/ovn/mech_driver/ovsdb/ovn_client.py index 96abc466e64..2b5adcad3c1 100644 --- a/neutron/plugins/ml2/drivers/ovn/mech_driver/ovsdb/ovn_client.py +++ b/neutron/plugins/ml2/drivers/ovn/mech_driver/ovsdb/ovn_client.py @@ -33,6 +33,7 @@ from neutron_lib.plugins import directory from neutron_lib.plugins import utils as p_utils from neutron_lib.services.logapi import constants as log_const from neutron_lib.services.qos import constants as qos_consts +from neutron_lib.services.trunk import constants as trunk_const from neutron_lib.utils import helpers from neutron_lib.utils import net as n_net from oslo_config import cfg @@ -292,6 +293,10 @@ class OVNClient(object): Defaults to True. """ cmd = [] + if db_port.device_owner == trunk_const.TRUNK_SUBPORT_OWNER: + # NOTE(ralonsoh): OVN subports don't have host ID information. + return + if up: if not db_port.port_bindings: return diff --git a/neutron/tests/unit/plugins/ml2/drivers/ovn/mech_driver/ovsdb/test_ovn_client.py b/neutron/tests/unit/plugins/ml2/drivers/ovn/mech_driver/ovsdb/test_ovn_client.py index 58ab1ef5258..b536d869d89 100644 --- a/neutron/tests/unit/plugins/ml2/drivers/ovn/mech_driver/ovsdb/test_ovn_client.py +++ b/neutron/tests/unit/plugins/ml2/drivers/ovn/mech_driver/ovsdb/test_ovn_client.py @@ -27,6 +27,7 @@ from neutron.tests.unit.services.logapi.drivers.ovn \ from neutron_lib.api.definitions import l3 from neutron_lib import constants as const from neutron_lib.services.logapi import constants as log_const +from neutron_lib.services.trunk import constants as trunk_const from tenacity import wait_none @@ -251,6 +252,15 @@ class TestOVNClient(TestOVNClientBase): 'Logical_Switch_Port', port_id, 'external_ids', constants.OVN_HOST_ID_EXT_ID_KEY, if_exists=True) + def test_update_lsp_host_info_trunk_subport(self): + context = mock.MagicMock() + db_port = mock.Mock(id='fake-port-id', + device_owner=trunk_const.TRUNK_SUBPORT_OWNER) + + self.ovn_client.update_lsp_host_info(context, db_port) + self.nb_idl.db_remove.assert_not_called() + self.nb_idl.db_set.assert_not_called() + @mock.patch.object(ml2_db, 'get_port') def test__wait_for_port_bindings_host(self, mock_get_port): context = mock.MagicMock()