From c0bdb0c8a33286acb4d44ad865f0000309fc79b6 Mon Sep 17 00:00:00 2001 From: Rodolfo Alonso Hernandez Date: Wed, 30 Oct 2024 18:08:15 +0000 Subject: [PATCH] [OVN] Check LSP.up status before setting the port host info Before executing updating the Logical_Swith_Port host information, it is needed to check the current status of the port. If it doesn't match with the event calling this update, the host information is not updated. Closes-Bug: #2085543 Change-Id: I92afb190375caf27c815f9fe1cb627e87c49d4ca --- .../ml2/drivers/ovn/mech_driver/ovsdb/ovn_client.py | 12 ++++++++++++ .../drivers/ovn/mech_driver/ovsdb/test_ovn_client.py | 1 + 2 files changed, 13 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 b291333e285..e04bcc755d2 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 @@ -299,7 +299,14 @@ class OVNClient: # NOTE(ralonsoh): OVN subports don't have host ID information. return + port_up = self._nb_idl.lsp_get_up(db_port.id).execute( + check_error=True) if up: + if not port_up: + LOG.warning('Logical_Switch_Port %s host information not ' + 'updated, the port state is down') + return + if not db_port.port_bindings: return @@ -321,6 +328,11 @@ class OVNClient: self._nb_idl.db_set( 'Logical_Switch_Port', db_port.id, ext_ids)) else: + if port_up: + LOG.warning('Logical_Switch_Port %s host information not ' + 'removed, the port state is up') + return + cmd.append( self._nb_idl.db_remove( 'Logical_Switch_Port', db_port.id, 'external_ids', 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 c7a517c3045..b23a76d6e0f 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 @@ -299,6 +299,7 @@ class TestOVNClient(TestOVNClientBase): context = mock.MagicMock() port_id = 'fake-port-id' db_port = mock.Mock(id=port_id) + self.nb_idl.lsp_get_up.return_value.execute.return_value = False self.ovn_client.update_lsp_host_info(context, db_port, up=False)