Skip to content

Commit e739716

Browse files
ralonsohdougszumski
authored andcommitted
[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
1 parent 986a0f0 commit e739716

2 files changed

Lines changed: 19 additions & 0 deletions

File tree

neutron/services/ovn_l3/exceptions.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,8 @@
1919
class MechanismDriverNotFound(n_exc.NotFound):
2020
message = _("None of the supported mechanism drivers found: "
2121
"%(mechanism_drivers)s. Check your configuration.")
22+
23+
24+
class MechanismDriverOVNNotReady(n_exc.ServiceUnavailable):
25+
message = _('Mechanism driver OVN connection not ready. This service '
26+
'plugin must be initialized after the mechanism driver.')

neutron/services/ovn_l3/plugin.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
from neutron_lib.api.definitions import qos_fip as qos_fip_apidef
2020
from neutron_lib.api.definitions import qos_gateway_ip as qos_gateway_ip_apidef
2121
from neutron_lib.callbacks import events
22+
from neutron_lib.callbacks import priority_group
2223
from neutron_lib.callbacks import registry
2324
from neutron_lib.callbacks import resources
2425
from neutron_lib import constants as n_const
@@ -94,6 +95,7 @@ def __init__(self):
9495
self.scheduler = l3_ovn_scheduler.get_scheduler()
9596
self.port_forwarding = port_forwarding.OVNPortForwarding(self)
9697
self.l3_driver_controller = driver_controller.DriverController(self)
98+
self.subscribe()
9799

98100
@staticmethod
99101
def _disable_qos_extensions_by_extension_drivers(aliases):
@@ -161,6 +163,18 @@ def get_plugin_description(self):
161163
return ("L3 Router Service Plugin for basic L3 forwarding"
162164
" using OVN")
163165

166+
def subscribe(self):
167+
# By default, the post fork initialization must be done first in the
168+
# ML2 plugin (the lower the priority number, the sooner is attended).
169+
registry.subscribe(self._post_fork_initialize,
170+
resources.PROCESS, events.AFTER_INIT,
171+
priority=priority_group.PRIORITY_DEFAULT + 1,
172+
cancellable=True)
173+
174+
def _post_fork_initialize(self, resource, event, trigger, payload=None):
175+
if not self._nb_ovn or not self._sb_ovn:
176+
raise ovn_l3_exc.MechanismDriverOVNNotReady()
177+
164178
def _add_neutron_router_interface(self, context, router_id,
165179
interface_info):
166180
try:

0 commit comments

Comments
 (0)