[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. Related-Bug: #2027605 Change-Id: I81390af2ea2fc384423518b84de3acf7adaf9193
This commit is contained in:
parent
d1bfc3d70a
commit
e1f887ca9f
@ -1080,3 +1080,10 @@ def validate_port_binding_and_virtual_port(
|
|||||||
raise n_exc.BadRequest(
|
raise n_exc.BadRequest(
|
||||||
resource='port',
|
resource='port',
|
||||||
msg='A virtual logical switch port cannot be bound to a host')
|
msg='A virtual logical switch port cannot be bound to a host')
|
||||||
|
|
||||||
|
|
||||||
|
def get_requested_chassis(requested_chassis):
|
||||||
|
"""Returns a list with the items in the LSP.options:requested-chassis"""
|
||||||
|
if isinstance(requested_chassis, str):
|
||||||
|
return requested_chassis.split(',')
|
||||||
|
return []
|
||||||
|
@ -277,6 +277,15 @@ class PortBindingChassisUpdateEvent(row_event.RowEvent):
|
|||||||
{'port': row.logical_port, 'binding': row.uuid})
|
{'port': row.logical_port, 'binding': row.uuid})
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
req_chassis = utils.get_requested_chassis(
|
||||||
|
row.options.get(ovn_const.LSP_OPTIONS_REQUESTED_CHASSIS_KEY, ''))
|
||||||
|
if len(req_chassis) > 1:
|
||||||
|
# This event has been issued during a LSP migration. During this
|
||||||
|
# process, the LSP will change the port binding but the port status
|
||||||
|
# will be handled by the ``LogicalSwitchPortUpdateDownEvent`` and
|
||||||
|
# ``LogicalSwitchPortUpdateUpEvent`` events.
|
||||||
|
return False
|
||||||
|
|
||||||
return bool(lsp.up)
|
return bool(lsp.up)
|
||||||
|
|
||||||
def run(self, event, row, old=None):
|
def run(self, event, row, old=None):
|
||||||
|
@ -357,6 +357,7 @@ class TestPortBindingChassisUpdateEvent(base.BaseTestCase):
|
|||||||
self.driver.set_port_status_up.assert_called()
|
self.driver.set_port_status_up.assert_called()
|
||||||
else:
|
else:
|
||||||
self.driver.set_port_status_up.assert_not_called()
|
self.driver.set_port_status_up.assert_not_called()
|
||||||
|
self.driver.set_port_status_up.reset_mock()
|
||||||
|
|
||||||
def test_event_matches(self):
|
def test_event_matches(self):
|
||||||
# NOTE(twilson) This primarily tests implementation details. If a
|
# NOTE(twilson) This primarily tests implementation details. If a
|
||||||
@ -366,10 +367,24 @@ class TestPortBindingChassisUpdateEvent(base.BaseTestCase):
|
|||||||
attrs={'name': 'Port_Binding'})
|
attrs={'name': 'Port_Binding'})
|
||||||
ovsdb_row = fakes.FakeOvsdbRow.create_one_ovsdb_row
|
ovsdb_row = fakes.FakeOvsdbRow.create_one_ovsdb_row
|
||||||
self.driver.nb_ovn.lookup.return_value = ovsdb_row(attrs={'up': True})
|
self.driver.nb_ovn.lookup.return_value = ovsdb_row(attrs={'up': True})
|
||||||
|
|
||||||
|
# Port binding change.
|
||||||
self._test_event(
|
self._test_event(
|
||||||
self.event.ROW_UPDATE,
|
self.event.ROW_UPDATE,
|
||||||
ovsdb_row(attrs={'_table': pbtable, 'chassis': 'one',
|
ovsdb_row(attrs={'_table': pbtable, 'chassis': 'one',
|
||||||
'type': '_fake_', 'logical_port': 'foo'}),
|
'type': '_fake_', 'logical_port': 'foo',
|
||||||
|
'options': {}}),
|
||||||
|
ovsdb_row(attrs={'_table': pbtable, 'chassis': 'two',
|
||||||
|
'type': '_fake_'}))
|
||||||
|
|
||||||
|
# Port binding change because of a live migration in progress.
|
||||||
|
options = {
|
||||||
|
ovn_const.LSP_OPTIONS_REQUESTED_CHASSIS_KEY: 'chassis1,chassis2'}
|
||||||
|
self._test_event(
|
||||||
|
self.event.ROW_UPDATE,
|
||||||
|
ovsdb_row(attrs={'_table': pbtable, 'chassis': 'one',
|
||||||
|
'type': '_fake_', 'logical_port': 'foo',
|
||||||
|
'options': options}),
|
||||||
ovsdb_row(attrs={'_table': pbtable, 'chassis': 'two',
|
ovsdb_row(attrs={'_table': pbtable, 'chassis': 'two',
|
||||||
'type': '_fake_'}))
|
'type': '_fake_'}))
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user