The NoDBTestCase base class does a lot of env setup that is not needed
for these tests. As we have issues with these tests (see bug 1823251)
this patch tries to decrease the complexity of them to help the
troubleshooting.
Change-Id: I46fafa470b9d378d96c0f364e9b487742bf58cb2
Related-Bug: #1823251
When hard-deleting an instance we first delete related records
but the code was not taking into account soft-deleted related
records which will result in the instance delete failing due to
a referential constraint because soft-deleted records are not
really deleted when it comes to table constraints.
This fixes the issue by simply passing read_deleted='yes' to the
related record model query in the hard delete path.
The related unit test is updated to cover this scenario and a
typo in that same test is also fixed here.
Change-Id: I9fc5a9cc40ceffc450c1fde1df7fb36581e9cc94
Closes-Bug: #1830438
Add a parameter to limit the archival of deleted rows by date. That is,
only rows related to instances deleted before provided date will be
archived.
This option works together with --max_rows, if both are specified both
will take effect.
Closes-Bug: #1751192
Change-Id: I408c22d8eada0518ec5d685213f250e8e3dae76e
Implements: blueprint nova-archive-before
_instance_update modifies its 'values' argument. Consequently if it is
retried due to an update conflict, the second invocation has the wrong
arguments.
A specific issue this causes is that if we called it with
expected_task_state a concurrent modification to task_state will cause
us to fail and retry. However, expected_task_state will have been popped
from values on the first invocation and will not be present for the
second. Consequently the second invocation will fail to perform the
task_state check and therefore succeed, resulting in a race.
We rewrite the old race unit test which wasn't testing the correct
thing for 2 reasons:
1. Due to the bug fixed in this patch, although we were calling
update_on_match() twice, the second call didn't check the task state.
2. side_effect=iterable returns function items without executing them,
but we weren't hitting this due to the bug fixed in this patch.
Closes-Bug: #1821373
Change-Id: I01c63e685113bf30e687ccb14a4d18e344b306f6
This patch adds a new parameter ``locked_reason`` to
``POST /servers/{server_id}/action`` request where the
action is lock. It enables the user to specify a reason when locking
a server.
The locked_reason will be exposed through ``GET servers/{server_id}``,
``GET /servers/detail``, ``POST /servers/{server_id}/action`` where
the action is rebuild and ``PUT servers/{server_id}`` requests' responses.
The InstanceActionNotification will emit the locked_reason
along with the other instance details. This patch hence changes the
payload object to include the "locked_reason" field.
Note that "locked" will be allowed as a valid filtering/sorting parameter
for ``GET /servers/detail`` and ``GET /servers`` from this new microversion.
Implements blueprint add-locked-reason
Change-Id: I46edd595e7417c584106487123774a73c6dbe65e
This patch adds a function, get_compute_nodes_by_host_or_node() to
the host manager to get ComputeNode objects by the given host name
and/or by the given node name.
Change-Id: Ic492766691741e3a8e4938ad90307cb2fe484cc5
Blueprint: use-placement-in-tree
In order to avoid a situation where an instance is both in cell0
and rebuilt *out of* cell0, we need to first hard delete the instance
in cell0. This change adds the ability to hard delete an instance from
a cell DB.
Change-Id: Ibf257276d879bfb409c00577607ae3b9712133fa
Implements: blueprint enable-rebuild-for-instances-in-cell0
Like the other reference table entries for an instance,
we should soft_delete virtual_interfaces when destroying
an instance. Failing to do so can lead to archive issues
due to the referential constraint.
Change-Id: I04355bdec5477b4c144105fea130089fe1ae6772
Closes-Bug: #1823781
Seeing as these were missed for Rocky, we really ought to get them in
for Stein.
Change-Id: I29401773a0686e7be5d7d1cbb5ec82ffbb16fb4a
Signed-off-by: Stephen Finucane <sfinucan@redhat.com>
Make use of the newer fixtures in oslo_db.sqlalchemy.test_fixtures
which is what was intended to supersede fixtures
in oslo_db.sqlalchemy.test_base.
Change-Id: Icb88c13336fffb499083197ed864b8e4e45dc241
Closes-Bug: #1797102
We've been seeing warnings emitted to the python 3 unit tests:
OsloDBDeprecationWarning: EngineFacade is deprecated; please use
oslo_db.sqlalchemy.enginefacade
which stem from our use of the get_legacy_facade() oslo.db method.
This replaces the get_legacy_facade() usage with the get_engine()
method from the transaction context manager.
Closes-Bug: #1795078
Change-Id: If1e355d6174f15a1880e97115a2cf3f9f4be837e
Add ``volume_type`` field to BlockDeviceMapping object to be used
in new instance block_device_mapping_v2.volume_type API extension.
Implements: blueprint boot-instance-specific-storage-backend
Change-Id: I66ff84585642ff8d40ecfefef3342349eb49f83d
This adds the changes-before filter to the servers,
os-instance-actions and os-migrations APIs for
filtering resources which were last updated before
or equal to the given time. The changes-before filter,
like the changes-since filter, will return deleted
server resources.
Part of bp support-to-query-nova-resources-filter-by-changes-before
Change-Id: If91c179e3823c8b0da744a9363906b0f7b05c326
The instance_create DB API creates an instance_id_mappings record
but instance_destroy was not cleaning it up when the instance is
deleted; this adds that delete code. Otherwise those records
never get moved to shadow tables so you can't archive and purge them.
Change-Id: Idfe52d3c2f987b9aac551f013a0990423d87fad3
Closes-Bug: #1786298
nova/db/__init__.py was importing * from nova.db.api. This meant that
any time any code anywhere within the nova.db package was imported
then nova.db.api was too, leading to a cascade of imports that may
not have been desired. Also, in general, code in __init__.py is a pain.
Therefore, this change adjusts code that so that either:
* nova.db.api is used directly
* nova.db.api is imported as 'db'
In either case, the functionality remains the same.
The primary goal of this change was to make it possible to import the
model files without having to import the db api. Moving the model files
to a different place in the directory hierarchy was considered, but
given that "code in __init__.py is a pain" this mode was chosen.
This looks like a very large change, but it is essentially adjusting
package names, many in mocks.
Change-Id: Ic1fd7c87ceda05eeb96735da2a415ef37060bb1a
Since Ifbd53b13fa0fef62e0329283b73d587f367e46c2 we no
longer have compat code in the InstanceGroup object
and everything is handled in the API database, so we can
drop the legacy DB API methods for instance groups.
Change-Id: I3816176ccd33995486a7cd19217bd76100f8bddf
Since Ifbd53b13fa0fef62e0329283b73d587f367e46c2 we no
longer have compat code in the InstanceGroup object
and everything is handled in the API database, so we can
drop the legacy DB API methods for instance groups.
This is part of a series of cleanup changes.
Change-Id: Ic1da9e2c36297784ddc2e7dc9e1a83146fa2292c
Since Ifbd53b13fa0fef62e0329283b73d587f367e46c2 we no
longer have compat code in the InstanceGroup object
and everything is handled in the API database, so we can
drop the legacy DB API methods for instance groups.
This is part of a series of cleanup changes.
Change-Id: I569ee5d582ce42d84afe2b4b6e702657abe8733b
We've had a long-standing optimization point in the
InstanceList.get_uuids_by_host() method, where we pull the entire
list of instance objects only to strip and return the uuids. We
already had a query method for generating just the uuids in the
DB API, but it was not exposed as it was just a helper for another
method. This exposes it publicly and uses it in that InstanceList
method.
Change-Id: I35c05e78d59ec9b95c2a443979b8d66cd42ea043
This change adds a trusted_certs deferred-load column to
instance_extras, which stores a list of trusted x509 certificate
UUIDs for a given instance in the form of a JSON blob.
Change-Id: I3fd4e395b31ff1b69f35242d559f8caa17c05a6a
Implements: blueprint nova-validate-certificates
We need this for the subsequent request_filter, which will do queries
based only on metadata value.
Related to blueprint placement-req-filter
Change-Id: I1325a226823329384edd7197e5d5f2725dc16e8f
The usage of objects in TestNewtonCellsCheck to create
records in the database was just a convenience when it
was written but as the models change we have to fallback
to using direct SQL execution, so this makes that change
for cell and host mappings as has been done before for
flavors.
Change-Id: If565bb11bf0fea07d7c9e5f0f6ba708e2ab8f378
We dropped support for aggregates in newton, so this compatibility code
should no longer be used or needed.
Related to blueprint placement-req-filter
Change-Id: Iec161b0b13b5d3fe655531eacad83193fea89fda
We haven't used this since the flavor migration compat
code was removed: I4107af592448e20fe929f8fa3112929e3685b581
Change-Id: I9f752fe01b0b1506691586e78f231b3dabe24698
We haven't used this since the flavor migration compat
code was removed: I4107af592448e20fe929f8fa3112929e3685b581
Change-Id: Ic167a6e7f1be7246ef57d157c2e485465902e512