Browse Source

Merge "Fix evacuation when host dies uncleanly"

tags/7.0.0.0b1
Zuul Gerrit Code Review 8 months ago
parent
commit
5e2f1a5ad0
1 changed files with 44 additions and 2 deletions
  1. +44
    -2
      networking_ovn/ovsdb/ovsdb_monitor.py

+ 44
- 2
networking_ovn/ovsdb/ovsdb_monitor.py View File

@@ -137,6 +137,47 @@ class ChassisEvent(row_event.RowEvent):
self.l3_plugin.schedule_unhosted_gateways()


class PortBindingChassisUpdateEvent(row_event.RowEvent):
"""Event for matching a port moving chassis

If the LSP is up and the Port_Binding chassis has just changed,
there is a good chance the host died without cleaning up the chassis
column on the Port_Binding. The port never goes down, so we won't
see update the driver with the LogicalSwitchPortUpdateUpEvent which
only monitors for transitions from DOWN to UP.
"""

def __init__(self, driver):
self.driver = driver
table = 'Port_Binding'
events = (self.ROW_UPDATE,)
super(PortBindingChassisUpdateEvent, self).__init__(
events, table, None)
self.event_name = self.__class__.__name__

def match_fn(self, event, row, old=None):
# NOTE(twilson) ROW_UPDATE events always pass old, but chassis will
# only be set if chassis has changed
old_chassis = getattr(old, 'chassis', None)
if not (row.chassis and old_chassis) or row.chassis == old_chassis:
return False
if row.type == ovn_const.OVN_CHASSIS_REDIRECT:
return False
try:
lsp = self.driver._nb_ovn.lookup('Logical_Switch_Port',
row.logical_port)
except idlutils.RowNotFound:
LOG.warning("Logical Switch Port %(port)s not found for "
"Port_Binding %(binding)s",
{'port': row.logical_port, 'binding': row.uuid})
return False

return bool(lsp.up)

def run(self, event, row, old=None):
self.driver.set_port_status_up(row.logical_port)


class PortBindingChassisEvent(row_event.RowEvent):
"""Port_Binding update event - set chassis for chassisredirect port.

@@ -459,8 +500,9 @@ class OvnSbIdl(OvnIdlDistributedLock):
"""
self._chassis_event = ChassisEvent(self.driver)
self._portbinding_event = PortBindingChassisEvent(self.driver)
self.notify_handler.watch_events([self._chassis_event,
self._portbinding_event])
self.notify_handler.watch_events(
[self._chassis_event, self._portbinding_event,
PortBindingChassisUpdateEvent(self.driver)])


def _check_and_set_ssl_files(schema_name):


Loading…
Cancel
Save