Skip to content

Commit 02c05a3

Browse files
committed
[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 (cherry picked from commit c0bdb0c)
1 parent 7e48691 commit 02c05a3

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

neutron/plugins/ml2/drivers/ovn/mech_driver/ovsdb/ovn_client.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,14 @@ def update_lsp_host_info(self, context, db_port, up=True):
294294
# NOTE(ralonsoh): OVN subports don't have host ID information.
295295
return
296296

297+
port_up = self._nb_idl.lsp_get_up(db_port.id).execute(
298+
check_error=True)
297299
if up:
300+
if not port_up:
301+
LOG.warning('Logical_Switch_Port %s host information not '
302+
'updated, the port state is down')
303+
return
304+
298305
if not db_port.port_bindings:
299306
return
300307

@@ -316,6 +323,11 @@ def update_lsp_host_info(self, context, db_port, up=True):
316323
self._nb_idl.db_set(
317324
'Logical_Switch_Port', db_port.id, ext_ids))
318325
else:
326+
if port_up:
327+
LOG.warning('Logical_Switch_Port %s host information not '
328+
'removed, the port state is up')
329+
return
330+
319331
cmd.append(
320332
self._nb_idl.db_remove(
321333
'Logical_Switch_Port', db_port.id, 'external_ids',

neutron/tests/unit/plugins/ml2/drivers/ovn/mech_driver/ovsdb/test_ovn_client.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,7 @@ def test_update_lsp_host_info_down(self):
164164
context = mock.MagicMock()
165165
port_id = 'fake-port-id'
166166
db_port = mock.Mock(id=port_id)
167+
self.nb_idl.lsp_get_up.return_value.execute.return_value = False
167168

168169
self.ovn_client.update_lsp_host_info(context, db_port, up=False)
169170

0 commit comments

Comments
 (0)