From 5ee7ac1261cb5cfa4b51dfd899f682d7e628ceae Mon Sep 17 00:00:00 2001 From: Rodolfo Alonso Hernandez Date: Wed, 11 Dec 2024 14:08:30 +0000 Subject: [PATCH] Read the environment variable EVENTLET_MONKEYPATCH Since eventlet 0.39.0 [1] it is possible to you set an environment variable ``EVENTLET_MONKEYPATCH=1`` to get patching as early as possible in Python startup, which may avoid some problems. [1]https://github.com/eventlet/eventlet/commit/b754135b045306022a537b5797f2cb2cf47ba49b Related-Bug: #2091538 Topic: eventlet-deprecation Change-Id: I928e32ea736bdb3357fdbb1de6646e69db3159d7 --- neutron/common/eventlet_utils.py | 9 +++++++++ ...riable_eventlet_monkeypatch-fccede7812d60c38.yaml | 12 ++++++++++++ 2 files changed, 21 insertions(+) create mode 100644 releasenotes/notes/env_variable_eventlet_monkeypatch-fccede7812d60c38.yaml diff --git a/neutron/common/eventlet_utils.py b/neutron/common/eventlet_utils.py index 7d88e01358c..babc70cf70d 100644 --- a/neutron/common/eventlet_utils.py +++ b/neutron/common/eventlet_utils.py @@ -13,6 +13,8 @@ # License for the specific language governing permissions and limitations # under the License. +import os + import eventlet @@ -22,6 +24,13 @@ IS_MONKEY_PATCHED = False def monkey_patch(): global IS_MONKEY_PATCHED if not IS_MONKEY_PATCHED: + # This environment variable will be used in eventlet 0.39.0 + # https://github.com/eventlet/eventlet/commit/ + # b754135b045306022a537b5797f2cb2cf47ba49b + if os.getenv('EVENTLET_MONKEYPATCH') == '1': + IS_MONKEY_PATCHED = True + return + eventlet.monkey_patch() # pylint: disable=import-outside-toplevel diff --git a/releasenotes/notes/env_variable_eventlet_monkeypatch-fccede7812d60c38.yaml b/releasenotes/notes/env_variable_eventlet_monkeypatch-fccede7812d60c38.yaml new file mode 100644 index 00000000000..411c43a3edf --- /dev/null +++ b/releasenotes/notes/env_variable_eventlet_monkeypatch-fccede7812d60c38.yaml @@ -0,0 +1,12 @@ +--- +features: + - | + Since eventlet 0.39.0, a new environment variable + ``EVENTLET_MONKEYPATCH=1`` can be defined to get patching as early as + possible in Python startup. +upgrade: + - | + Neutron can read the environment variable ``EVENTLET_MONKEYPATCH=1`` in + order to not monkey patch the system libraries. If this environment + variable is set and the eventlet version is lower, the process won't be + patched.