Skip to content

Commit df8a4b6

Browse files
ralonsohAlex-Welsh
authored andcommitted
Skip OVNL3 post-fork init in non-API workers
The ``OVNL3RouterPlugin`` registers OVN OVSDB monitor events during ``_post_fork_initialize``. That callback is also invoked from neutron-periodic-workers and other non-API processes, where the OVN IDL connections are not initialized. Checking OVN readiness before filtering by worker type raised ``MechanismDriverOVNNotReady`` and blocked worker startup. Return early when the trigger is not a Neutron API ``WorkerService``, and only then validate OVN readiness and register monitor events. Conflicts: neutron/services/ovn_l3/plugin.py Related-Bug: #2154192 Signed-off-by: Rodolfo Alonso Hernandez <ralonsoh@redhat.com> Change-Id: I9e43fdb06ce7868e5fa699657d8da9a4aa4d02fb (cherry picked from commit b6d260e)
1 parent cde40ac commit df8a4b6

2 files changed

Lines changed: 18 additions & 8 deletions

File tree

neutron/services/ovn_l3/plugin.py

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -183,18 +183,20 @@ def subscribe(self):
183183
cancellable=True)
184184

185185
def _post_fork_initialize(self, resource, event, trigger, payload=None):
186+
# TODO(ralonsoh): once [1] is released and required in Neutron, it
187+
# won't be needed the ``get_method_class`` method.
188+
# [1] https://review.opendev.org/c/openstack/neutron-lib/+/988563
189+
if utils.get_method_class(trigger) != wsgi.WorkerService:
190+
return
191+
186192
if not self._nb_ovn or not self._sb_ovn:
187193
raise ovn_l3_exc.MechanismDriverOVNNotReady()
188194

189195
# Register needed events, only for the Neutron API workers.
190-
# TODO(ralonsoh): once [1] is released and required in Neutron, it
191-
# won't be needed the ``get_method_class`` method.
192-
# [1] https://review.opendev.org/c/openstack/neutron-lib/+/988563
193-
if utils.get_method_class(trigger) == wsgi.WorkerService:
194-
self._nb_ovn.idl.notify_handler.watch_events([
195-
ovsdb_monitor.LogicalRouterPortEvent(self),
196-
ovsdb_monitor.LogicalRouterPortGatewayChassisEvent(self),
197-
])
196+
self._nb_ovn.idl.notify_handler.watch_events([
197+
ovsdb_monitor.LogicalRouterPortEvent(self),
198+
ovsdb_monitor.LogicalRouterPortGatewayChassisEvent(self),
199+
])
198200

199201
def _add_neutron_router_interface(self, context, router_id,
200202
interface_info):
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
---
2+
fixes:
3+
- |
4+
The ``OVNL3RouterPlugin._post_fork_initialize`` method now returns early
5+
when the worker is not a Neutron API ``WorkerService`` instance. This
6+
prevents ``MechanismDriverOVNNotReady`` errors in the
7+
``neutron-periodic-workers`` and other non-API processes, where the OVN
8+
IDL connections are not initialized.

0 commit comments

Comments
 (0)