Fix eventlet.tpool import

Currently nova.utils.tpool_execute() only works by chance. And as the
bug report shows there are env where it fails.

The nova.utils.tpool_execute() call tries to uses eventlet.tpool.execute
but the tpool module is not imported by the utils module only eventlet.
In devstack it works by chance as the wsgi init actually imports
eventlet.tpool indirectly via:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/opt/stack/nova/nova/api/openstack/compute/__init__.py", line 21, in <module>
    from nova.api.openstack.compute.routes import APIRouterV21 # noqa
  File "/opt/stack/nova/nova/api/openstack/compute/routes.py", line 20, in <module>
    from nova.api.openstack.compute import admin_actions
  File "/opt/stack/nova/nova/api/openstack/compute/admin_actions.py", line 17, in <module>
    from nova.api.openstack import common
  File "/opt/stack/nova/nova/api/openstack/common.py", line 27, in <module>
    from nova.compute import task_states
  File "/opt/stack/nova/nova/compute/task_states.py", line 26, in <module>
    from nova.objects import fields
  File "/opt/stack/nova/nova/objects/fields.py", line 24, in <module>
    from nova.network import model as network_model
  File "/opt/stack/nova/nova/network/model.py", line 23, in <module>
    from nova import utils
  File "/opt/stack/nova/nova/utils.py", line 39, in <module>
    from oslo_concurrency import processutils
  File "/usr/local/lib/python3.8/dist-packages/oslo_concurrency/processutils.py", line 57, in <module>
    from eventlet import tpool

This was broken since I8dbc579e0037969aab4f2bb500fccfbde4190726. This
patch adds the correct import statement.

Change-Id: Ic46345ceeb445164aea6ae9b35c457c6150765f6
Closes-Bug: #1915400
This commit is contained in:
Balazs Gibizer 2022-02-22 12:24:37 +01:00
parent 28cbcbb373
commit b2d28f8908

View File

@ -29,6 +29,7 @@ import shutil
import tempfile
import eventlet
from eventlet import tpool
from keystoneauth1 import loading as ks_loading
import netaddr
from openstack import connection
@ -685,7 +686,7 @@ def spawn_n(func, *args, **kwargs):
def tpool_execute(func, *args, **kwargs):
"""Run func in a native thread"""
eventlet.tpool.execute(func, *args, **kwargs)
tpool.execute(func, *args, **kwargs)
def is_none_string(val):