Merge "[OVN] Check LSP.up status before setting the port host info"

This commit is contained in:
Zuul 2024-11-05 17:01:51 +00:00 committed by Gerrit Code Review
commit 52f5b3e812
2 changed files with 13 additions and 0 deletions

View File

@ -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',

View File

@ -298,6 +298,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)