From 76f343c5868556f12f9ee74b7ef2291cf5e2ff85 Mon Sep 17 00:00:00 2001 From: Rodolfo Alonso Hernandez Date: Wed, 31 Jul 2024 10:53:14 +0000 Subject: [PATCH] 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 --- neutron/wsgi/api.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/neutron/wsgi/api.py b/neutron/wsgi/api.py index ad5ba332a27..7fbafb0f65a 100644 --- a/neutron/wsgi/api.py +++ b/neutron/wsgi/api.py @@ -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()