Default native threading for sch, api and metadata
This patch switches the default concurrency mode to native threading for the services that gained native threading support in Flamingo: nova-scheduler, nova-api, and nova-metadata. The OS_NOVA_DISABLE_EVENTLET_PATCHING env variable still can be used to explicitly switch the concurrency mode to eventlet by OS_NOVA_DISABLE_EVENTLET_PATCHING=false We also ensure that the cover, docs, py3xx and functional tox targets are still running with eventlet while py312-threading kept running with native threading. Change-Id: I86c7f31f19ca3345218171f0abfa8ddd4f8fc7ea Signed-off-by: Balazs Gibizer <gibi@redhat.com>
This commit is contained in:
8 changed files with 71 additions and 13 deletions
@@ -21,14 +21,21 @@ up support for the native threading mode.
Selecting concurrency mode for a service
----------------------------------------
Nova still uses Eventlet by default, but allows switching services to native
threading mode at service startup via setting the environment variable
``OS_NOVA_DISABLE_EVENTLET_PATCHING=true``.
Since nova 33.0.0 (2026.1 Gazpacho) the nova-scheduler, nova-api, and
nova-metadata are using native threading by default. The rest of the
services are using eventlet by default in this release. The concurrency mode
can be configured via setting the environment variable
``OS_NOVA_DISABLE_EVENTLET_PATCHING``. Setting that variable to ``true``
requests the native threading mode while setting it to ``false`` requests the
eventlet mode. If the variable is not set the above default is applied.
.. note::
Since nova 32.0.0 (2025.2 Flamingo) the nova-scheduler, nova-metadata,
nova-api, and nova-conductor can be switched to native threading mode.
Since nova 32.0.0 (2025.2 Flamingo) the nova-scheduler, nova-metadata, and
nova-api can be switched to native threading mode.
Since nova 33.0.0 (2026.1 Gazpacho) also the nova-conductor can be switched
to native threading mode.
Tunables for the native threading mode
@@ -16,7 +16,7 @@
"""Starter script for Nova Scheduler."""
# autopep8: off
from nova import monkey_patch; monkey_patch.patch() # noqa
from nova import monkey_patch; monkey_patch.patch(backend='threading') # noqa
# autopep8: on
import sys
@@ -72,10 +72,29 @@ def _monkey_patch():
return True
def patch():
if (os.environ.get('OS_NOVA_DISABLE_EVENTLET_PATCHING', '').lower()
not in ('1', 'true', 'yes')):
def patch(backend='eventlet'):
"""Apply eventlet monkey patching according to environment.
:param backend: Defines the default backend if not explicitly set via
the environment. If 'eventlet', then monkey patch if environment
variable is not defined. If 'threading', then do not monkey patch if
environment variable is not defined. Any other value results in a
ValueError. If the environment variable is defined this parameter
is ignored.
"""
if backend not in ('eventlet', 'threading'):
raise ValueError(
"the backend can only be 'eventlet' or 'threading'")
env = os.environ.get('OS_NOVA_DISABLE_EVENTLET_PATCHING', '').lower()
if env == '':
should_patch = (backend == 'eventlet')
elif env in ('1', 'true', 'yes'):
should_patch = False
else:
should_patch = True
if should_patch:
if _monkey_patch():
global MONKEY_PATCHED
MONKEY_PATCHED = True
@@ -1691,3 +1691,17 @@ class OsloServiceBackendSelectionTestCase(test.NoDBTestCase):
"OS_NOVA_DISABLE_EVENTLET_PATCHING set to 'true', but then the "
"service tried to call eventlet.monkey_patch(). This is a bug.",
str(ex))
@mock.patch('oslo_service.backend.init_backend')
def test_threading_selected_by_default(self, init_backend):
with mock.patch.dict(os.environ):
del os.environ["OS_NOVA_DISABLE_EVENTLET_PATCHING"]
monkey_patch.patch(backend='threading')
init_backend.assert_called_once_with(
oslo_backend.BackendType.THREADING)
def test_invalid_default_backend(self):
ex = self.assertRaises(ValueError, monkey_patch.patch, backend='foo')
self.assertEqual(
"the backend can only be 'eventlet' or 'threading'", str(ex))
@@ -12,7 +12,7 @@
"""WSGI application entry-point for Nova Metadata API."""
# autopep8: off
from nova import monkey_patch; monkey_patch.patch() # noqa
from nova import monkey_patch; monkey_patch.patch(backend='threading') # noqa
# autopep8: on
import threading
@@ -12,7 +12,7 @@
"""WSGI application entry-point for Nova Compute API."""
# autopep8: off
from nova import monkey_patch; monkey_patch.patch() # noqa
from nova import monkey_patch; monkey_patch.patch(backend='threading') # noqa
# autopep8: on
import threading
@@ -0,0 +1,9 @@
---
features:
- |
The default concurrency mode is now switched from eventlet to native
threading for nova-scheduler, nova-api, and nova-metadata services.
The concurrency mode can still be switched back to eventlet if needed.
Please read the
`concurrency <https://docs.openstack.org/nova/latest/admin/concurrency.html>`__
guide for more details.
13
tox.ini
13
tox.ini
@@ -56,12 +56,14 @@ commands =
env TEST_OSPROFILER=1 stestr run --combine --no-discover 'nova.tests.unit.test_profiler'
stestr slowest
[testenv:{unit,py3,py310,py311,py312}]
[testenv:{unit,py3,py310,py311,py312,py313}]
setenv =
{[testenv]setenv}
# we do not have any greenlet leaks in unit tests so enforce that
# by making greenlet leaks a failure.
NOVA_RAISE_ON_GREENLET_LEAK=True
# run the test with eventlet
OS_NOVA_DISABLE_EVENTLET_PATCHING=False
[testenv:py312-threading]
setenv =
@@ -81,7 +83,7 @@ commands =
stestr run {posargs} --exclude-list /tmp/exclude.txt
stestr slowest
[testenv:functional{,-py310,-py311,-py312}]
[testenv:functional{,-py310,-py311,-py312,-py313}]
description =
Run functional tests.
setenv =
@@ -89,6 +91,8 @@ setenv =
# we do not have any greenlet leaks in functional tests so enforce that
# by making greenlet leaks a failure.
NOVA_RAISE_ON_GREENLET_LEAK=True
# run the test with eventlet
OS_NOVA_DISABLE_EVENTLET_PATCHING=False
# As nova functional tests import the PlacementFixture from the placement
# repository these tests are, by default, set up to run with openstack-placement
# from pypi. In the gate, Zuul will use the installed version of placement (stable
@@ -208,6 +212,8 @@ commands =
setenv =
{[testenv]setenv}
PYTHON=coverage run --source nova --parallel-mode
# run the test with eventlet
OS_NOVA_DISABLE_EVENTLET_PATCHING=False
extras =
commands =
coverage erase
@@ -244,6 +250,9 @@ commands =
sphinx-build -W --keep-going -b html -j auto doc/source doc/build/html
# Test the redirects. This must run after the main docs build
whereto doc/build/html/.htaccess doc/test/redirect-tests.txt
setenv =
OS_NOVA_DISABLE_EVENTLET_PATCHING=False
[testenv:pdf-docs]
description =
Reference in New Issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.