[eventlet-removal] Remove the usage of eventlet in the Neutron API

This patch removes the usage of eventlet in the Neutron API, but
only in the API process; that means the OVN maintenance worker (in case
of using ML2/OVN), the periodic worker or the RPC server are still
importing it and monkey patching the kernel libraries.

Related-Bug: #2087953
Change-Id: Icd15d8f1da02b9a2f074c00de4378bc0692a3b64
This commit is contained in:
Rodolfo Alonso Hernandez
2025-01-08 13:39:50 +00:00
parent 7031da2cc2
commit 3ff599700c
6 changed files with 52 additions and 9 deletions

View File

@ -62,3 +62,30 @@ This implementation does not rely on ``neutron.api.wsgi.Server`` nor
configuration variable. Right now only the embedded form (local thread)
is implemented (``metadata_workers=0``, the default value). Future
implementations will enable again this configuration variable.
Neutron API
-----------
The Neutron API currently can be executed only with the uWSGI module; the
eventlet executor has been deprecated, although the code has not been removed
from the repository yet.
The Neutron API consists of the following executables:
* The API server: is a multiprocess worker; each process is created by the
``uWSGI`` server.
* The periodic worker: a mult process worker that spawns several threads to
execute the periodic workers.
* The RPC worker: a multiprocess process worker that attends the requests from
the RPC clients, for example the Neutron agents.
* The ML2/OVN maintenance worker: single process worker, needed by the ML2/OVN
mechanism driver.
.. note::
Right now, only the API server is running without eventlet.

View File

@ -11,7 +11,6 @@
# under the License.
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
@ -26,10 +25,6 @@ def main_rpc_eventlet():
server.boot_server(rpc_eventlet.eventlet_rpc_server)
def main_api_eventlet():
return server.boot_server(api_eventlet.eventlet_api_server)
def main_periodic_eventlet():
server.boot_server(periodic_eventlet.eventlet_periodic_workers)

View File

@ -0,0 +1,21 @@
# Copyright (c) 2025 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 import server
from neutron.server import api
def main_api_uwsgi():
return server.boot_server(api.api_server)

View File

@ -24,7 +24,7 @@ from neutron.common import config
from neutron.common import profiler
def eventlet_api_server():
def api_server():
profiler.setup('neutron-server', cfg.CONF.host)
app = config.load_paste_app('neutron')
registry.publish(resources.PROCESS, events.BEFORE_SPAWN,

View File

@ -22,10 +22,10 @@ eventlet_utils.monkey_patch()
import threading # noqa:E402
from neutron import server # noqa:E402
from neutron.server import api_eventlet # noqa:E402
from neutron.server import api # noqa:E402
application = None
lock = threading.Lock()
with lock:
if application is None:
application = server.boot_server(api_eventlet.eventlet_api_server)
application = server.boot_server(api.api_server)

View File

@ -31,7 +31,7 @@ data_files =
[entry_points]
wsgi_scripts =
neutron-api = neutron.cmd.eventlet.server:main_api_eventlet
neutron-api = neutron.cmd.server:main_api_uwsgi
console_scripts =
neutron-db-manage = neutron.db.migration.cli:main
neutron-dhcp-agent = neutron.cmd.eventlet.agents.dhcp:main