[OVN] Match LSP_TYPE_VIRTUAL in PortBindingUpdateVirtualPortsEvent

With newer versions of OVN, port bindings are removed and added
for both virtual ports and container ports (aka trunk ports in
Neutron world)[1][2].

With this, Neutron recently landed a change in order to handle
virtual ports for the update/delete steps[3], however, this has
resulted in unexpected behaviour where the binding information
is wiped for trunk ports, then subsequently removed on the
next maintenance run.

We should make sure that we only have row deletes for
virtual ports specifically rather than all ports.

[1]: ec933537f9
[2]: 28d40c0a02
[3]: https://review.opendev.org/c/openstack/neutron/+/883681

Related-Bug: #2024160
Change-Id: Ide3204748274cbab9731310c2e2bd8bd8c9a53ff
(cherry picked from commit 1160aaa471)
This commit is contained in:
Mohammed Naser 2023-09-26 20:02:55 +00:00 committed by Rodolfo Alonso Hernandez
parent 4de1ddf4e3
commit 2319e7c35f
2 changed files with 14 additions and 7 deletions

View File

@ -557,7 +557,7 @@ class PortBindingUpdateVirtualPortsEvent(row_event.RowEvent):
if event == self.ROW_DELETE:
# The port binding has been deleted, delete the host ID (if the
# port was not deleted before).
return True
return row.type == ovn_const.LSP_TYPE_VIRTUAL
virtual_parents = (row.options or {}).get(
ovn_const.LSP_OPTIONS_VIRTUAL_PARENTS_KEY)

View File

@ -359,12 +359,6 @@ class TestNBDbMonitor(base.TestOVNFunctionalBase):
# and the corresponding "virtual-parents".
self._check_port_binding_type(vip['id'], ovn_const.LSP_TYPE_VIRTUAL)
self._check_port_virtual_parents(vip['id'], port['id'])
n_utils.wait_until_true(lambda: mock_update_vip_host.called,
timeout=10)
# The "Port_Binding" has been deleted. Then the "Port_Binding" register
# is created again without virtual_parents, but this event doesn't
# call "update_virtual_port_host".
mock_update_vip_host.assert_called_once_with(vip['id'], None)
# 2) Unset the allowed address pairs.
# Assign the VIP again and delete the virtual port.
@ -405,6 +399,19 @@ class TestNBDbMonitor(base.TestOVNFunctionalBase):
# if this behaviour is changed.
mock_update_vip_host.assert_called_with(vip['id'], None)
@mock.patch.object(mech_driver.OVNMechanismDriver,
'update_virtual_port_host')
def test_non_virtual_port_no_host_update(self, mock_update_vip_host):
# The ``PortBindingUpdateVirtualPortsEvent`` delete event should affect
# only to virtual ports. This check is done for virtual ports in
# ``test_virtual_port_host_update``.
port = self.create_port()
self._delete('ports', port['id'])
# We actively wait for 5 seconds for the ``Port_Binding`` event to
# arrive and be processed, but the port host must not be updated.
self.assertRaises(n_utils.WaitTimeout, n_utils.wait_until_true,
lambda: mock_update_vip_host.called, timeout=5)
class TestNBDbMonitorOverTcp(TestNBDbMonitor):
def get_ovsdb_server_protocol(self):