Skip to content

Commit 2319e7c

Browse files
mnaserralonsoh
authored andcommitted
[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]: ovn-org/ovn@ec93353 [2]: ovn-org/ovn@28d40c0 [3]: https://review.opendev.org/c/openstack/neutron/+/883681 Related-Bug: #2024160 Change-Id: Ide3204748274cbab9731310c2e2bd8bd8c9a53ff (cherry picked from commit 1160aaa)
1 parent 4de1ddf commit 2319e7c

File tree

2 files changed

+14
-7
lines changed

2 files changed

+14
-7
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -557,7 +557,7 @@ def match_fn(self, event, row, old):
557557
if event == self.ROW_DELETE:
558558
# The port binding has been deleted, delete the host ID (if the
559559
# port was not deleted before).
560-
return True
560+
return row.type == ovn_const.LSP_TYPE_VIRTUAL
561561

562562
virtual_parents = (row.options or {}).get(
563563
ovn_const.LSP_OPTIONS_VIRTUAL_PARENTS_KEY)

neutron/tests/functional/plugins/ml2/drivers/ovn/mech_driver/ovsdb/test_ovsdb_monitor.py

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -359,12 +359,6 @@ def test_virtual_port_host_update(self, mock_update_vip_host):
359359
# and the corresponding "virtual-parents".
360360
self._check_port_binding_type(vip['id'], ovn_const.LSP_TYPE_VIRTUAL)
361361
self._check_port_virtual_parents(vip['id'], port['id'])
362-
n_utils.wait_until_true(lambda: mock_update_vip_host.called,
363-
timeout=10)
364-
# The "Port_Binding" has been deleted. Then the "Port_Binding" register
365-
# is created again without virtual_parents, but this event doesn't
366-
# call "update_virtual_port_host".
367-
mock_update_vip_host.assert_called_once_with(vip['id'], None)
368362

369363
# 2) Unset the allowed address pairs.
370364
# Assign the VIP again and delete the virtual port.
@@ -405,6 +399,19 @@ def test_virtual_port_host_update(self, mock_update_vip_host):
405399
# if this behaviour is changed.
406400
mock_update_vip_host.assert_called_with(vip['id'], None)
407401

402+
@mock.patch.object(mech_driver.OVNMechanismDriver,
403+
'update_virtual_port_host')
404+
def test_non_virtual_port_no_host_update(self, mock_update_vip_host):
405+
# The ``PortBindingUpdateVirtualPortsEvent`` delete event should affect
406+
# only to virtual ports. This check is done for virtual ports in
407+
# ``test_virtual_port_host_update``.
408+
port = self.create_port()
409+
self._delete('ports', port['id'])
410+
# We actively wait for 5 seconds for the ``Port_Binding`` event to
411+
# arrive and be processed, but the port host must not be updated.
412+
self.assertRaises(n_utils.WaitTimeout, n_utils.wait_until_true,
413+
lambda: mock_update_vip_host.called, timeout=5)
414+
408415

409416
class TestNBDbMonitorOverTcp(TestNBDbMonitor):
410417
def get_ovsdb_server_protocol(self):

0 commit comments

Comments
 (0)