[OVN] Add a new process to spawn ML2/OVN maintenance worker

When using the Neutron WSGI module, the ML2/OVN maintenance worker needs
to be spawned in a separate service. This patch adds the service
``neutron-ovn-maintenance-worker``, that is a single process service tha
runs the ``MaintenanceWorker`` instance. This process is in charge of
performing periodic routines related to the ML2/OVN driver.

This new service should be included in any deployment project that
allows to spawn Neutron ML2/OVN with WSGI. Along with this patch, a new
one for devstack will be proposed.

Related-Bug: #1912359
Change-Id: Iea2995adb3343aae74a1b617fbccfce5c62c6b87
This commit is contained in:
Rodolfo Alonso Hernandez 2024-06-17 07:10:03 +00:00 committed by Rodolfo Alonso
parent 811f74d943
commit 980f9bdab2
4 changed files with 64 additions and 0 deletions
neutron
setup.cfg

@ -12,6 +12,7 @@
from neutron import server
from neutron.server import api_eventlet
from neutron.server import ovn_maintenance
from neutron.server import periodic_eventlet
from neutron.server import rpc_eventlet
from neutron.server import wsgi_eventlet
@ -31,3 +32,7 @@ def main_api_eventlet():
def main_periodic_eventlet():
server.boot_server(periodic_eventlet.eventlet_periodic_workers)
def main_ovn_maintenance_eventlet():
return server.boot_server(ovn_maintenance.eventlet_ovn_maintenance_worker)

@ -0,0 +1,42 @@
# Copyright 2024 Red Hat, Inc.
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
from neutron_lib.api import attributes
from oslo_log import log
from neutron._i18n import _
from neutron.api import extensions
from neutron import manager
from neutron import service
LOG = log.getLogger(__name__)
def eventlet_ovn_maintenance_worker():
LOG.info('Eventlet OVN maintenance process starting...')
try:
manager.init()
ext_mgr = extensions.PluginAwareExtensionManager.get_instance()
ext_mgr.extend_resources('2.0', attributes.RESOURCES)
ovn_maintenance_worker = service.start_ovn_maintenance_worker()
if not ovn_maintenance_worker:
raise RuntimeError(_('OVN maintenance worker not loaded, ML2/OVN '
'mechanism driver must be used'))
except NotImplementedError:
LOG.info('OVN maintenance worker was already started in parent '
'process by plugin.')
else:
ovn_maintenance_worker.wait()

@ -38,6 +38,8 @@ from neutron.api import wsgi
from neutron.common import config
from neutron.common import profiler
from neutron.conf import service
from neutron.plugins.ml2.drivers.ovn.mech_driver.ovsdb import worker as \
ovn_worker
from neutron import worker as neutron_worker
@ -226,6 +228,12 @@ def _get_plugins_workers():
]
def _get_ovn_maintenance_worker():
for worker in _get_plugins_workers():
if isinstance(worker, ovn_worker.MaintenanceWorker):
return worker
class AllServicesNeutronWorker(neutron_worker.NeutronBaseWorker):
def __init__(self, services, worker_process_count=1):
super(AllServicesNeutronWorker, self).__init__(worker_process_count)
@ -322,6 +330,14 @@ def start_plugins_workers():
return _start_workers(plugins_workers)
def start_ovn_maintenance_worker():
ovn_maintenance_worker = _get_ovn_maintenance_worker()
if not ovn_maintenance_worker:
return
return _start_workers([ovn_maintenance_worker])
def _get_api_workers():
workers = cfg.CONF.api_workers
if workers is None:

@ -60,6 +60,7 @@ console_scripts =
neutron-periodic-workers = neutron.cmd.eventlet.server:main_periodic_eventlet
neutron-status = neutron.cmd.status:main
neutron-ovn-agent = neutron.cmd.eventlet.agents.ovn_neutron_agent:main
neutron-ovn-maintenance-worker = neutron.cmd.eventlet.server:main_ovn_maintenance_eventlet
neutron-ovn-metadata-agent = neutron.cmd.eventlet.agents.ovn_metadata:main
neutron-ovn-migration-mtu = neutron.cmd.ovn.migration_mtu:main
neutron-ovn-db-sync-util = neutron.cmd.ovn.neutron_ovn_db_sync_util:main