Skip to content

Commit 1098929

Browse files
mnederloffernandoroyosanchez
authored andcommitted
[OVN] Fix virtual parent match for PortBindingUpdateVirtualPortsEvent
As mentioned in change [1], the condition should be a `is None` as per inline comment. [1] https://review.opendev.org/c/openstack/neutron/+/896883 Related-Bug: #2038413 Change-Id: I3666cf0509747863ca2a416c8bfc065582573734 (cherry picked from commit 170d99f)
1 parent 0d8cc09 commit 1098929

File tree

2 files changed

+60
-1
lines changed

2 files changed

+60
-1
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
@@ -568,7 +568,7 @@ def match_fn(self, event, row, old):
568568
# which means we need to update the host_id information
569569
return True
570570

571-
if getattr(old, 'options', None) is not None:
571+
if getattr(old, 'options', None) is None:
572572
# The "old.options" dictionary is not being modified,
573573
# thus the virtual parents didn't change.
574574
return False

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

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -329,6 +329,65 @@ def test_event_matches(self):
329329
'type': '_fake_'}))
330330

331331

332+
class TestPortBindingUpdateVirtualPortsEvent(base.BaseTestCase):
333+
def setUp(self):
334+
super().setUp()
335+
self.event = ovsdb_monitor.PortBindingUpdateVirtualPortsEvent(None)
336+
337+
self.pbtable = fakes.FakeOvsdbTable.create_one_ovsdb_table(
338+
attrs={'name': 'Port_Binding'})
339+
self.ovsdb_row = fakes.FakeOvsdbRow.create_one_ovsdb_row
340+
341+
self.row = self.ovsdb_row(
342+
attrs={'_table': self.pbtable,
343+
'chassis': 'newchassis',
344+
'options': {
345+
'virtual-parents': 'uuid1,uuid2'}})
346+
347+
def test_delete_event_matches(self):
348+
# Delete event (only type virtual).
349+
self.assertFalse(self.event.match_fn(
350+
self.event.ROW_DELETE,
351+
self.ovsdb_row(attrs={'_table': self.pbtable, 'type': '_fake_'}),
352+
None))
353+
self.assertTrue(self.event.match_fn(
354+
self.event.ROW_DELETE,
355+
self.ovsdb_row(attrs={'_table': self.pbtable, 'type': 'virtual'}),
356+
None))
357+
358+
def test_event_no_match_no_options(self):
359+
# Unrelated portbind change (no options in old, so no virtual parents)
360+
self.assertFalse(self.event.match_fn(
361+
self.event.ROW_UPDATE, self.row,
362+
self.ovsdb_row(attrs={'_table': self.pbtable,
363+
'name': 'somename'})))
364+
365+
def test_event_no_match_other_options_change(self):
366+
# Non-virtual parent change, no chassis has changed
367+
old = self.ovsdb_row(attrs={'_table': self.pbtable,
368+
'options': {
369+
'virtual-parents': 'uuid1,uuid2',
370+
'other-opt': '_fake_'}})
371+
372+
self.assertFalse(self.event.match_fn(self.event.ROW_UPDATE,
373+
self.row, old))
374+
375+
def test_event_match_chassis_change(self):
376+
# Port binding change (chassis changed, and marked in old)
377+
self.assertTrue(self.event.match_fn(
378+
self.event.ROW_UPDATE, self.row,
379+
self.ovsdb_row(attrs={'_table': self.pbtable,
380+
'chassis': 'fakechassis'})))
381+
382+
def test_event_match_virtual_parent_change(self):
383+
# Virtual parent change
384+
old = self.ovsdb_row(attrs={'_table': self.pbtable,
385+
'options': {
386+
'virtual-parents': 'uuid1,uuid3'}})
387+
self.assertTrue(self.event.match_fn(self.event.ROW_UPDATE,
388+
self.row, old))
389+
390+
332391
class TestOvnNbIdlNotifyHandler(test_mech_driver.OVNMechanismDriverTestCase):
333392

334393
def setUp(self):

0 commit comments

Comments
 (0)