Commit Graph

61509 Commits

Author SHA1 Message Date
Zuul 6b4c19fddf Merge "Implement sound model extra spec for libvirt." 2025-07-24 14:24:39 +00:00
Zuul 940d85fc6b Merge "api: Add response body schemas for removed APIs" 2025-07-24 06:11:06 +00:00
Zuul fa13535aac Merge "libvirt: Add objects and notifications for sound model." 2025-07-23 17:14:27 +00:00
Zuul 6053bb2722 Merge "api: Address issues with server group APIs" 2025-07-22 21:14:35 +00:00
Zuul 240c4a0605 Merge "api: Add response body schemas for server group APIs" 2025-07-22 18:13:13 +00:00
Zuul f315c7b581 Merge "Make the default executor configurable" 2025-07-22 16:48:11 +00:00
Zuul 5ede0cd027 Merge "Rename DEFAULT_GREEN_POOL to DEFAULT_EXECUTOR" 2025-07-22 16:47:58 +00:00
Zuul c741689878 Merge "api: Add response body schemas for server password APIs" 2025-07-22 13:48:35 +00:00
Zuul 2010536d12 Merge "api: Add response body schemas for server external events API" 2025-07-21 21:43:12 +00:00
Zuul 2a8ae9eae7 Merge "Make nova.utils.pass_context private" 2025-07-18 15:23:31 +00:00
Zuul 770a6f1eab Merge "Move ConductorManager to use spawn_on" 2025-07-17 16:17:57 +00:00
Zuul f484c4089d Merge "Add Project Manager role context in unit tests" 2025-07-16 17:19:32 +00:00
Zuul 03f41a7f8a Merge "FUP: Translate scatter-gather to futurist" 2025-07-16 17:19:20 +00:00
Zuul 19d621a66f Merge "Move ComputeManager to use spawn_on" 2025-07-16 12:09:12 +00:00
Balazs Gibizer c5feba11ff Make the default executor configurable
This patch adds the logic to initialize our DEFAULT_EXECUTOR based on
the concurrency mode.

If the OS_NOVA_DISABLE_EVENTLET_PATCHING env variable is set to "true"
then we use ThreadPoolExecutor so the service will use native threads.
Otherwise the service will keep using the GreenThreadPoolExecutor and
therefore using Eventlet.

There is a new config option `[DEFAULT]default_thread_pool_size`
added to define the size of the ThreadPoolExecutor and the existing
`[DEFAULT]default_green_pool_size` is deprecated. The two config options
are independent and each of them is only used if the service is started
with the matching concurrency mode.

Our test fixture that catches leaked threads are adapted to handle both
threading mode. But at the moment it is only tested with the eventlet
mode as no service can be switched to threading mode yet.

Change-Id: I17b8065e8b14f0401297258e43dc2a98031d61f4
Signed-off-by: Balazs Gibizer <gibi@redhat.com>
2025-07-11 15:28:12 +02:00
Balazs Gibizer cc0c57b73a Rename DEFAULT_GREEN_POOL to DEFAULT_EXECUTOR
Now that we are using executors we can clarify the naming of the global
and the function accessing it.

Change-Id: Iddaa1e9c72f8f32168996edcfacf93d6df16e7a7
Signed-off-by: Balazs Gibizer <gibi@redhat.com>
2025-07-11 15:28:12 +02:00
Balazs Gibizer f9eb35a384 Make nova.utils.pass_context private
All our thread spawning should pass the context and all should go
through either spawn to use the default executor or spawn_on with a
specific executor. Right now pass_context is only called locally in the
utils module. We make it private to signal that it is intentional.

This is a pure refactor with two steps:
* remove the public pass_context as it is unused by removing it from the
  internall call chain of spawn and spawn_on
* rename _pass_context_wrapper

This change does not effect any existing behavior so no test changes
were needed.

Change-Id: I5ad19b5c1a6d489c0f7df7fcbd9f87858b03760c
Signed-off-by: Balazs Gibizer <gibi@redhat.com>
2025-07-11 15:18:13 +02:00
Balazs Gibizer bf04b66b4a Move ConductorManager to use spawn_on
So far the ConductorManager.cache_images functionality used an
explicit GreenPool. We change this pool to a GreenThreadPoolExecutor
and use then spawn_on to start the thread. This way we can
* can replace the direct eventlet dependency with an indirect one behind
  an interface where the impl can easily switched out to
  ThreadPoolExecutor in the future
* we can get rid of the explicit pass_context call and centralize that
  instead to spawn_*

We don't have unit test changes here as we have good unit tests that are
asserting behavior not asserting implementation. So when the implementation
changes (like in this refactor patch) but the behavior does not, we don't
need to change the existing unit test coverage.

The existing test coverage is in:
  nova.tests.unit.conductor.test_conductor.ConductorTaskAPITest

Change-Id: I15297fd7869ed5f8a58f0ca599ef11df91e04de6
Signed-off-by: Balazs Gibizer <gibi@redhat.com>
2025-07-11 15:17:59 +02:00
Balazs Gibizer 3b99b8a6e9 FUP: Translate scatter-gather to futurist
Small fixes for Ibff6c73ad9af911a42204e53fee31ed5537c829d

Change-Id: I288c48476a5cd6f0f657f29aab6246500fe52765
Signed-off-by: Balazs Gibizer <gibi@redhat.com>
2025-07-11 12:55:16 +00:00
OpenStack Proposal Bot 547a002cc5 Imported Translations from Zanata
For more information about this automatic import see:
https://docs.openstack.org/i18n/latest/reviewing-translation-import.html

Change-Id: I16cbd61c8dae4bddc32341d267e43b1681ce1dc4
Signed-off-by: OpenStack Proposal Bot <openstack-infra@lists.openstack.org>
Generated-By: openstack/openstack-zuul-jobs:roles/prepare-zanata-client/files/common_translation_update.sh
2025-07-11 04:17:16 +00:00
Zuul 54b65d5bf2 Merge "Add spawn_on" 2025-07-10 18:00:39 +00:00
Zuul 1b4b1d4e99 Merge "api: Address issues with keypairs APIs" 2025-07-10 13:15:07 +00:00
Stephen Finucane 8f9cbe0015 api: Add response body schemas for removed APIs
These are all empty and are purely here to satisfy the check for
schemas and to allow us to potentially populate them for documentation
purposes later.

Change-Id: Ia52bc78b3392ec69382f3427f5676d52f9abee6d
Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
2025-07-10 11:39:22 +01:00
Stephen Finucane e249f5762d api: Address issues with server group APIs
* Set additionalProperties to False, as expected
* Correct copy calls (not that it matters)

Change-Id: I97d8206d2df5deee0521ae69a73a32a7136c37be
Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
2025-07-10 11:38:44 +01:00
Stephen Finucane 04589a4530 api: Add response body schemas for server group APIs
Another relatively trivial one.

Change-Id: I4a5ae398e141ff29db6888b5ace731c689c7d239
Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
2025-07-10 11:38:38 +01:00
Stephen Finucane 558a870e13 api: Add response body schemas for server password APIs
This must be the easiest one yet.

Change-Id: I57e359068215a91452fd5f4d9044c04ecfc83fc2
Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
2025-07-10 11:38:38 +01:00
Stephen Finucane 8ed52a058a api: Add response body schemas for server external events API
We also fix some issues in the api-ref, since it'll be another while
before we can replace that.

Change-Id: If661e3af796475637c0e76b3dfbfd5b7a7f38c24
Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
2025-07-10 11:38:38 +01:00
Michael Still dab248718d Implement sound model extra spec for libvirt.
This is the implementation for the sound model extra spec as
desired by the new libvirt spice-direct console mode. Sound
support is a frequently requested feature for VDI users.

Change-Id: I33b8fc0136b4c1783b5c493e8ca9a15110767f6c
Signed-off-by: Michael Still <mikal@stillhq.com>
2025-07-07 14:44:57 +10:00
Michael Still 183896a79b libvirt: Add objects and notifications for sound model.
This patch adds just the objects and notifications required to
support an extra spec to configure a sound device inside
the guest. This is useful for SPICE consoles using the native
protocol.

Change-Id: I2faeda0fd0fb9c8894d69558a1ccaab8da9f6a1b
Signed-off-by: Michael Still <mikal@stillhq.com>
2025-07-07 14:44:57 +10:00
Zuul 1c03429337 Merge "Replace utils.spawn_n with spawn" 2025-07-04 18:00:25 +00:00
Zuul eff31bbb2d Merge "db: Resolve alembic deprecation warning" 2025-07-04 13:16:23 +00:00
Zuul 7bfcf82846 Merge "Use futurist for _get_default_green_pool()" 2025-07-03 17:11:12 +00:00
Balazs Gibizer 5c180e1761 Move ComputeManager to use spawn_on
So far the ComputeManager._sync_power_state functionality used an
explicit GreenPool. We change this pool to a GreenThreadPoolExecutor
and use then spawn_on to start the thread. This way we can
* can replace the direct eventlet dependency with an indirect one behind
  an interface where the impl can easily switched out to
  ThreadPoolExecutor in the future
* we can get rid of the explicit pass_context call and centralize that
  instead to spawn_*

The ComputeManager live_migration_executor is already a
GreenThreadPoolExecutor so here we only switching to spawn_on to get rid
of the explicit pass_context call.

Change-Id: I51c5339d3f54f5c66856b6d4e06cd91ac04977cb
Signed-off-by: Balazs Gibizer <gibi@redhat.com>
2025-07-02 15:47:29 +02:00
Balazs Gibizer b215c6fee9 Add spawn_on
Now that spawn is using the default executor and returns a Future we can
have a spawn_on that takes the executor as a parameter so the
scatter-gather code path can use the same context passing logic but use
a separate executor.

This also change spawn() to use spawn_on() with the default executor.
And warns if the executor is busy an therefore the task is queued.

During testing this we discovered that SpawnIsSynchronous fixture made a
wrong assumption that eventlet.spawn(f) would raise the exception if f
raises. It does not. So now when we changed this fixture to the new
executor structure we fixed this test bug. There was two unit test
cases that depended on the wrong behavior they are adapted now.

Change-Id: I3bb40f5d2446dfd06253371d6abe8d3449b11265
Signed-off-by: Balazs Gibizer <gibi@redhat.com>
2025-07-02 15:47:29 +02:00
Balazs Gibizer 81a03ab824 Replace utils.spawn_n with spawn
As [1] switched over the implementation of spawn and spawn_n to the same
futurist Executor.submit we can now replace all spawn_n usage with spawn
and drop spawn_n from nova.utils.

[1]I3494660e1aaa1db46f9f08494cb5817ec7020cc5

Change-Id: I0027f119c0fbe8d5298307324eaf30c5e9e152d3
Signed-off-by: Balazs Gibizer <gibi@redhat.com>
2025-07-02 15:47:29 +02:00
Balazs Gibizer d90e7726c0 Use futurist for _get_default_green_pool()
Nova uses nova.utils.spawn* to create new threads. This so far relied on
a GreenPool to provide GreenThreads. We changes this pool to a
futurist.GreenThreadPoolExecutor to have an interface where the
implementation can be swapped out to futurist.ThreadPoolExecutor to get
native threads instead.

This is an interface change on utils.spawn as it will return
futurist.Future instead of GreenThread. So couple of fixes needed across
nova to use:
* .result() instead of .wait()
* .add_done_callback() instead of .link(). Here we needed to change the
  usage as the new callback does not forward args, so we rely on
  closures instead.

This is also an interface and a behavior change for utils.spawn_n as it
now calls utils.spawn internally. This means that top of the above
detailed interface change there is behavior change for spawn_n.

The spawn creates GreenThread a wrapper around greenlet while spawn_n
created only the underlying greenlet. The greenlet cannot be managed
the same way as a more intelligent GreenThread, including the return
value but not limited to it, e.g. the whole cancellation mechanism
is missing from greenlet too. After this patch spawn_n will also use
GreenThread instead of naked greenlet. We consider the resulting small
performance change negligible.

Also the way we implement SpawnIsSynchronousFixture in our test is
adapted along with other test fixture adaptation to call / mock the
right functions.

Change-Id: I3494660e1aaa1db46f9f08494cb5817ec7020cc5
Signed-off-by: Balazs Gibizer <gibi@redhat.com>
2025-07-02 15:47:29 +02:00
Zuul 2c19c07d5e Merge "doc: Adding link for RabbitMQ installation during nova deployment on controller node." 2025-07-01 22:33:40 +00:00
Zuul 43d57ae63d Merge "api: Address issues with server diagnostics APIs" 2025-06-27 20:29:16 +00:00
Zuul bb71b953c7 Merge "api: Address issues with remote consoles APIs" 2025-06-27 17:32:18 +00:00
Zuul 7e26a95d2d Merge "Note on RPC error decorators around build_and_run_instance" 2025-06-27 16:42:15 +00:00
Zuul 39793dde08 Merge "Fix neutron client dict grabbing" 2025-06-27 16:41:59 +00:00
Zuul 76ad55da2e Merge "api: Add response body schemas for server diagnostics API" 2025-06-27 15:15:54 +00:00
Stephen Finucane c4f81a54d5 api: Address issues with remote consoles APIs
* Add a note explaining presence of xvpvnc console type
* Make 'url' mandatory in create response
* Remove unnecessary description fields: we will populate these later
* De-deuplcate request body schemas
* Re-add references to the rdp console to the api-ref

Change-Id: I5555b8cf7a83fad689e98522850b5550b49566ed
Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
2025-06-26 18:49:59 +01:00
Zuul 0d586ccca8 Merge "api: Add response body schemas for server topology API" 2025-06-26 13:31:51 +00:00
Zuul 3cc03f8a91 Merge "api: Add response body schemas for image metadata APIs" 2025-06-26 11:35:06 +00:00
Zuul 448578bf82 Merge "Translate scatter-gather to futurist" 2025-06-26 11:34:20 +00:00
Zuul b3d64d5f8f Merge "api: Add response body schemas for keypairs APIs" 2025-06-26 07:19:56 +00:00
Zuul d748e78486 Merge "api: Add response body schemas for remote consoles" 2025-06-26 02:23:22 +00:00
Balazs Gibizer 1cd1c472bd Note on RPC error decorators around build_and_run_instance
The RPC handler build_and_run_instance has a normal set of error handler
decorators but that call immediately spawns a separate thread and does not
wait for its result so it cannot get any exceptions. Therefore the error
handling should happen inside the thread. And it does. Mostly.

The _locked_do_build_and_run_instance is the function run by the thread
and it calls _do_build_and_run_instance. The _do_build_and_run_instance
has `except Exception` handling dropping the active exception and returning
an error value instead. So most of the exceptions are handled by
_do_build_and_run_instance without going through any of the error
decorators.

Whatever exception still bubbles up from _do_build_and_run_instance
are going through the error handling decorators top of
_do_build_and_run_instance.

The only source of exception outside of _do_build_and_run_instance but
within _locked_do_build_and_run_instance is
delete_allocation_for_instance. Exception from that call does not
go though any error handling decorators.

These error decorators has multiple tasks:
* wrap_exception calls _emit_legacy_exception_notification and
  _emit_versioned_exception_notification so sending error
  notifications
* reverts_task_state sets instance.task_state to None
* wrap_instance_fault records InstanceFault object to the DB

So there are two cases when error happens but the decorators are not
called:
* _do_build_and_run_instance catches the exception, does its own error
  handling and cleanup and then returns an error value. The task state
  revert and the InstanceFault creation is replicated to the individual
  cleanup sections here.
  Note that notification sending is not missing either as that is
  handled by the _build_and_run_instance called from
  _do_build_and_run_instance.

* delete_allocation_for_instance raises when called from
  _locked_do_build_and_run_instance. We reach this call if
  _do_build_and_run_instance failed already and did its own cleanup. So
  again task state are already reset and InstanceFault already recorded
  for the original fault and notification already sent.

So the only changes here is to add a note to build_and_run_instance so
that the real error handling are deeper in the stack so that readers will
not think error handling happen on top of the call stack.

There was two unit test cases that partially relied on the wrong
assumption that exceptions propagate to build_and_run_instance.
They could make that wrong assumption because the
SpawnIsSynchronousFixture simulates the GreenThread interface wrongly.
The goal of that fixture is to make any spawn (and spawn_n) call
synchronous meaning the function passed in is executed right away before
spawn returns. That is OK. But the fixture forgot that if the function
raises then such exception is now raised by spawn. Such a thing never
happens with a normal spawn. The exception (and the function return
value) only propagated when GreenThread.wait() is called.

So this patch fixes the fixture and corrects the two unit tests as well.

Change-Id: I440fff6663d0663fb1630dd096f352403982aa37
2025-06-25 17:59:02 +02:00
Balazs Gibizer 7d946c4535 Fix neutron client dict grabbing
Due to a bug in python3.13 [1] the following code will leads to an
emptied dict by the GC even though we hold a reference to the dict.

import gc

class A:

    def __init__(self, client):
        self.__dict__ = client.__dict__
        self.client = client

class B:
    def __init__(self):
        self.test_attr = "foo"

a = A(B())
print(a.__dict__)
print(a.client.__dict__)
gc.collect()
print("##  After gc.collect()")
print(a.__dict__)
print(a.client.__dict__)

 # Output with Python 13
{'test_attr': 'foo', 'client': <__main__.B object at 0x73ea355a8590>}
{'test_attr': 'foo', 'client': <__main__.B object at 0x73ea355a8590>}
 ##  After gc.collect()
{'test_attr': 'foo', 'client': <__main__.B object at 0x73ea355a8590>}
{}

 # Output with Python 12
{'test_attr': 'foo', 'client': <__main__.B object at 0x79c86f355400>}
{'test_attr': 'foo', 'client': <__main__.B object at 0x79c86f355400>}
 ##  After gc.collect()
{'test_attr': 'foo', 'client': <__main__.B object at 0x79c86f355400>}
{'test_attr': 'foo', 'client': <__main__.B object at 0x79c86f355400>

Our neutron client has this kind of code and therefore failing in
python3.13. This patch adds __getattr__ instead of trying to hold a
direct reference to the __dict__. This seems to work around the
problem.

Co-Authored-By: Johannes Kulik <johannes.kulik@sap.com>

[1] https://github.com/python/cpython/issues/130327
Closes-Bug: #2103413

Change-Id: I87c9fbb9331135674232c6e77d700966a938b0ac
2025-06-25 10:37:03 +02:00