From 1da88a61a856da6867db8afe0c5b051dfb2ee8fc Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Herv=C3=A9=20Beraud?= <hberaud@redhat.com>
Date: Thu, 30 Jan 2025 10:42:38 +0100
Subject: [PATCH] deprecate eventlet monkey patch within lockutils

Change-Id: I83352849192489e6918898969b92ee3f8e2bca55
---
 oslo_concurrency/lockutils.py                         |  3 +++
 ...te-eventlet-within-lockutils-cba49086d7a65042.yaml | 11 +++++++++++
 requirements.txt                                      |  1 +
 3 files changed, 15 insertions(+)
 create mode 100644 releasenotes/notes/deprecate-eventlet-within-lockutils-cba49086d7a65042.yaml

diff --git a/oslo_concurrency/lockutils.py b/oslo_concurrency/lockutils.py
index 2111486..4685d80 100644
--- a/oslo_concurrency/lockutils.py
+++ b/oslo_concurrency/lockutils.py
@@ -25,6 +25,7 @@ import tempfile
 import threading
 import weakref
 
+import debtcollector
 import fasteners
 from oslo_config import cfg
 from oslo_utils import reflection
@@ -98,6 +99,8 @@ class ReaderWriterLock(fasteners.ReaderWriterLock):
         # environment
         if eventlet is not None and eventlet_patcher is not None:
             if eventlet_patcher.is_monkey_patched('thread'):
+                debtcollector.deprecate(
+                    "Eventlet support is deprecated and will be removed.")
                 self._current_thread = eventlet.getcurrent
 
 
diff --git a/releasenotes/notes/deprecate-eventlet-within-lockutils-cba49086d7a65042.yaml b/releasenotes/notes/deprecate-eventlet-within-lockutils-cba49086d7a65042.yaml
new file mode 100644
index 0000000..ac96063
--- /dev/null
+++ b/releasenotes/notes/deprecate-eventlet-within-lockutils-cba49086d7a65042.yaml
@@ -0,0 +1,11 @@
+---
+deprecations:
+  - |
+    Eventlet usages are deprecated and the removal of Eventlet from
+    OpenStack `is planned <https://governance.openstack.org/tc//goals/proposed/remove-eventlet.html>`_,
+    for this reason, using the ``lockutils`` module of oslo.concurrency in a
+    monkey patched environment is now deprecated. The support of Eventlet will
+    be soon removed from oslo.concurrency.
+
+    Please start considering removing your internal Eventlet usages and
+    start migrating your stack.
diff --git a/requirements.txt b/requirements.txt
index b106d86..ebfd391 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -7,3 +7,4 @@ oslo.config>=5.2.0 # Apache-2.0
 oslo.i18n>=3.15.3 # Apache-2.0
 oslo.utils>=3.33.0 # Apache-2.0
 fasteners>=0.7.0 # Apache-2.0
+debtcollector>=3.0.0 # Apache-2.0