Skip to content

Commit 6a9990d

Browse files
committed
[OVN] Skip the port status UP update during a live migration
Skip the port status UP update during a live migration due to a ``PortBindingChassisUpdateEvent`` event. The port status will be set by the ``LogicalSwitchPortCreateUpEvent`` and ``LogicalSwitchPortCreateDownEvent`` events, that will be issued when the port is deleted from the source host and created in the destination host. This is a planned operation and controlled by Nova, not a reactive event due to an unplanned host down event. Conflicts: neutron/common/ovn/utils.py Related-Bug: #2027605 Change-Id: I81390af2ea2fc384423518b84de3acf7adaf9193 (cherry picked from commit e1f887c)
1 parent 9a537fd commit 6a9990d

File tree

3 files changed

+32
-1
lines changed

3 files changed

+32
-1
lines changed

neutron/common/ovn/utils.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -844,3 +844,10 @@ def get_ovn_chassis_other_config(chassis):
844844
return chassis.other_config
845845
except AttributeError:
846846
return chassis.external_ids
847+
848+
849+
def get_requested_chassis(requested_chassis):
850+
"""Returns a list with the items in the LSP.options:requested-chassis"""
851+
if isinstance(requested_chassis, str):
852+
return requested_chassis.split(',')
853+
return []

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -277,6 +277,15 @@ def match_fn(self, event, row, old=None):
277277
{'port': row.logical_port, 'binding': row.uuid})
278278
return False
279279

280+
req_chassis = utils.get_requested_chassis(
281+
row.options.get(ovn_const.LSP_OPTIONS_REQUESTED_CHASSIS_KEY, ''))
282+
if len(req_chassis) > 1:
283+
# This event has been issued during a LSP migration. During this
284+
# process, the LSP will change the port binding but the port status
285+
# will be handled by the ``LogicalSwitchPortUpdateDownEvent`` and
286+
# ``LogicalSwitchPortUpdateUpEvent`` events.
287+
return False
288+
280289
return bool(lsp.up)
281290

282291
def run(self, event, row, old=None):

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

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -357,6 +357,7 @@ def _test_event(self, event, row, old):
357357
self.driver.set_port_status_up.assert_called()
358358
else:
359359
self.driver.set_port_status_up.assert_not_called()
360+
self.driver.set_port_status_up.reset_mock()
360361

361362
def test_event_matches(self):
362363
# NOTE(twilson) This primarily tests implementation details. If a
@@ -366,10 +367,24 @@ def test_event_matches(self):
366367
attrs={'name': 'Port_Binding'})
367368
ovsdb_row = fakes.FakeOvsdbRow.create_one_ovsdb_row
368369
self.driver.nb_ovn.lookup.return_value = ovsdb_row(attrs={'up': True})
370+
371+
# Port binding change.
372+
self._test_event(
373+
self.event.ROW_UPDATE,
374+
ovsdb_row(attrs={'_table': pbtable, 'chassis': 'one',
375+
'type': '_fake_', 'logical_port': 'foo',
376+
'options': {}}),
377+
ovsdb_row(attrs={'_table': pbtable, 'chassis': 'two',
378+
'type': '_fake_'}))
379+
380+
# Port binding change because of a live migration in progress.
381+
options = {
382+
ovn_const.LSP_OPTIONS_REQUESTED_CHASSIS_KEY: 'chassis1,chassis2'}
369383
self._test_event(
370384
self.event.ROW_UPDATE,
371385
ovsdb_row(attrs={'_table': pbtable, 'chassis': 'one',
372-
'type': '_fake_', 'logical_port': 'foo'}),
386+
'type': '_fake_', 'logical_port': 'foo',
387+
'options': options}),
373388
ovsdb_row(attrs={'_table': pbtable, 'chassis': 'two',
374389
'type': '_fake_'}))
375390

0 commit comments

Comments
 (0)