[OVN] Add a post fork initialization method in OVN L3

This is the base implementation of a post fork initialization, happening
after the initialization of the "process" resource. This event happens
after the WSGI workers are already setup.

Related-Bug: #2125553
Signed-off-by: Rodolfo Alonso Hernandez <ralonsoh@redhat.com>
Change-Id: If708b969d86940dbec9956c58a4b22271aa9a198
This commit is contained in:
Rodolfo Alonso Hernandez
2025-10-16 07:08:44 +00:00
committed by Rodolfo Alonso
parent 9abf2d8360
commit 2ed024bb6f
2 changed files with 19 additions and 0 deletions

View File

@@ -19,3 +19,8 @@ from neutron_lib import exceptions as n_exc
class MechanismDriverNotFound(n_exc.NotFound):
message = _("None of the supported mechanism drivers found: "
"%(mechanism_drivers)s. Check your configuration.")
class MechanismDriverOVNNotReady(n_exc.ServiceUnavailable):
message = _('Mechanism driver OVN connection not ready. This service '
'plugin must be initialized after the mechanism driver.')

View File

@@ -19,6 +19,7 @@ from neutron_lib.api.definitions import provider_net as pnet
from neutron_lib.api.definitions import qos_fip as qos_fip_apidef
from neutron_lib.api.definitions import qos_gateway_ip as qos_gateway_ip_apidef
from neutron_lib.callbacks import events
from neutron_lib.callbacks import priority_group
from neutron_lib.callbacks import registry
from neutron_lib.callbacks import resources
from neutron_lib import constants as n_const
@@ -94,6 +95,7 @@ class OVNL3RouterPlugin(service_base.ServicePluginBase,
self.scheduler = l3_ovn_scheduler.get_scheduler()
self.port_forwarding = port_forwarding.OVNPortForwarding(self)
self.l3_driver_controller = driver_controller.DriverController(self)
self.subscribe()
@staticmethod
def _disable_qos_extensions_by_extension_drivers(aliases):
@@ -161,6 +163,18 @@ class OVNL3RouterPlugin(service_base.ServicePluginBase,
return ("L3 Router Service Plugin for basic L3 forwarding"
" using OVN")
def subscribe(self):
# By default, the post fork initialization must be done first in the
# ML2 plugin (the lower the priority number, the sooner is attended).
registry.subscribe(self._post_fork_initialize,
resources.PROCESS, events.AFTER_INIT,
priority=priority_group.PRIORITY_DEFAULT + 1,
cancellable=True)
def _post_fork_initialize(self, resource, event, trigger, payload=None):
if not self._nb_ovn or not self._sb_ovn:
raise ovn_l3_exc.MechanismDriverOVNNotReady()
def _add_neutron_router_interface(self, context, router_id,
interface_info):
try: