Monkey patch the system libraries before calling them

The Neutron API with WSGI module, and specifically when using ML2/OVN,
was importing some system libraries before patching them. That was
leading to a recursion error, as reported in the related LP bug.
By calling ``eventlet_utils.monkey_patch()`` at the very beginning
of the WSGI entry point [1], this issue is fixed.

[1] WSGI entry point:
  $ cat /etc/neutron/neutron-api-uwsgi.ini
  ...
  module = neutron.wsgi.api:application

Closes-Bug: #2075147
Change-Id: If2aa37b2a510a85172da833ca20564810817d246
This commit is contained in:
Rodolfo Alonso Hernandez 2024-07-31 10:53:14 +00:00 committed by Rodolfo Alonso
parent f1585775d9
commit 76f343c586

View File

@ -12,10 +12,17 @@
"""WSGI application entry-point for Neutron API."""
import threading
# NOTE: the WSGI module needs to monkey patch the libraries before any other
# module loads them. That will prevent the recursion error in the SSL library
# reported in LP#2075147
# pylint: disable=wrong-import-position
from neutron.common import eventlet_utils
eventlet_utils.monkey_patch()
from neutron import server
from neutron.server import api_eventlet
import threading # noqa:E402
from neutron import server # noqa:E402
from neutron.server import api_eventlet # noqa:E402
application = None
lock = threading.Lock()