Skip to content

Commit ad285c4

Browse files
Zuulopenstack-gerrit
authored andcommitted
Merge "[OVN] Check LSP.up status before setting the port host info" into stable/2023.1
2 parents 161a6b5 + 02c05a3 commit ad285c4

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)