Browse Source

Merge "Fix evacuation when host dies uncleanly"

tags/7.0.0.0b1
Zuul 1 week 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):
137 137
             self.l3_plugin.schedule_unhosted_gateways()
138 138
 
139 139
 
140
+class PortBindingChassisUpdateEvent(row_event.RowEvent):
141
+    """Event for matching a port moving chassis
142
+
143
+    If the LSP is up and the Port_Binding chassis has just changed,
144
+    there is a good chance the host died without cleaning up the chassis
145
+    column on the Port_Binding. The port never goes down, so we won't
146
+    see update the driver with the LogicalSwitchPortUpdateUpEvent which
147
+    only monitors for transitions from DOWN to UP.
148
+    """
149
+
150
+    def __init__(self, driver):
151
+        self.driver = driver
152
+        table = 'Port_Binding'
153
+        events = (self.ROW_UPDATE,)
154
+        super(PortBindingChassisUpdateEvent, self).__init__(
155
+            events, table, None)
156
+        self.event_name = self.__class__.__name__
157
+
158
+    def match_fn(self, event, row, old=None):
159
+        # NOTE(twilson) ROW_UPDATE events always pass old, but chassis will
160
+        # only be set if chassis has changed
161
+        old_chassis = getattr(old, 'chassis', None)
162
+        if not (row.chassis and old_chassis) or row.chassis == old_chassis:
163
+            return False
164
+        if row.type == ovn_const.OVN_CHASSIS_REDIRECT:
165
+            return False
166
+        try:
167
+            lsp = self.driver._nb_ovn.lookup('Logical_Switch_Port',
168
+                                             row.logical_port)
169
+        except idlutils.RowNotFound:
170
+            LOG.warning("Logical Switch Port %(port)s not found for "
171
+                        "Port_Binding %(binding)s",
172
+                        {'port': row.logical_port, 'binding': row.uuid})
173
+            return False
174
+
175
+        return bool(lsp.up)
176
+
177
+    def run(self, event, row, old=None):
178
+        self.driver.set_port_status_up(row.logical_port)
179
+
180
+
140 181
 class PortBindingChassisEvent(row_event.RowEvent):
141 182
     """Port_Binding update event - set chassis for chassisredirect port.
142 183
 
@@ -459,8 +500,9 @@ class OvnSbIdl(OvnIdlDistributedLock):
459 500
         """
460 501
         self._chassis_event = ChassisEvent(self.driver)
461 502
         self._portbinding_event = PortBindingChassisEvent(self.driver)
462
-        self.notify_handler.watch_events([self._chassis_event,
463
-                                          self._portbinding_event])
503
+        self.notify_handler.watch_events(
504
+            [self._chassis_event, self._portbinding_event,
505
+             PortBindingChassisUpdateEvent(self.driver)])
464 506
 
465 507
 
466 508
 def _check_and_set_ssl_files(schema_name):

Loading…
Cancel
Save