Commit Graph

48369 Commits

Author SHA1 Message Date
Matt Riedemann e315fcbec9 api-ref: fix server status values in GET /servers docs
The server status values exposed out of the API and used
for filtering when listing instances comes from the values
in nova.api.openstack.common._STATE_MAP. Some of the values
listed in the docs were incorrectly using variable names from
the code, which don't necessarily match the actual value exposed
out of the API.

The compute API server concepts guide actually had this all
correct, so this just updates the API reference.

Change-Id: I30b6f27c6e7fc9365c203b620b311785f8b4b489
Closes-Bug: #1722403
2017-10-11 16:33:15 -04:00
Jenkins 5846690de6 Merge "Fix sending legacy instance.update notification" 2017-10-10 20:09:52 +00:00
Jenkins b5e188fc77 Merge "use already loaded BDM in instance.create" 2017-10-10 20:08:27 +00:00
Jenkins 253aad457f Merge "Transform aggregate.add_host notification" 2017-10-10 15:34:10 +00:00
Jenkins 1995b60c15 Merge "Only query BDMs once in API during rebuild" 2017-10-10 14:50:14 +00:00
Jenkins 232458ae4e Merge "rp: Move RP._get|set_aggregates() to module scope" 2017-10-10 06:27:52 +00:00
Jenkins 650c9f3f08 Merge "nova.utils.get_ksa_adapter()" 2017-10-10 03:09:40 +00:00
Jenkins e3d32aa5fa Merge "rp: de-ORM ResourceProvider.get_by_uuid()" 2017-10-10 02:43:09 +00:00
Jenkins 083ca83401 Merge "use already loaded BDM in instance.<action> (2)" 2017-10-09 21:24:37 +00:00
Jenkins d3daf15e7b Merge "use already loaded BDM in instance.<action>" 2017-10-09 21:18:39 +00:00
Jenkins 91f5fc2b4a Merge "Always put 'uuid' into sort_keys for stable instance lists" 2017-10-09 20:59:35 +00:00
Jenkins bedb33ef04 Merge "Remove dead code of api.fault notification sending" 2017-10-09 20:12:44 +00:00
Jenkins de90377721 Merge "Make setenv consistent for unit, func, and api-samples" 2017-10-09 17:42:16 +00:00
Jenkins 0e6935168e Merge "Fix typo in test_prep_resize_errors_migration" 2017-10-09 17:30:39 +00:00
Jenkins 1f30865d6f Merge "Pre-create migration object" 2017-10-09 17:30:02 +00:00
Jenkins 5aaa429a8c Merge "Remove useless periodic task that expires quota reservations" 2017-10-09 17:27:05 +00:00
Jay Pipes 9d400c3a0a rp: Move RP._get|set_aggregates() to module scope
Instead of ResourceProvider._get_aggregates() and
ResourceProvider._set_aggregates() being @classmethods, move them to
being module-level functions to be consistent with the similar
functions for inventory and allocation information.

blueprint: de-orm-resource-providers

Change-Id: I52db9b4ca89aeb2a4ce9d10820bdac6fabf43ea4
2017-10-09 09:10:08 -07:00
Jay Pipes 2415c2e564 rp: de-ORM ResourceProvider.get_by_uuid()
This patch series aims to remove the use of SQLAlchemy ORM querying
from the nova/objects/resource_provider.py module. Currently, there is
a mix of non-ORM (SQLAlchemy core expression API) and ORM (SQLAlchemy's
orm module and associated query generation from model reflection).

While implementing the database schema for the nested resource
providers table structure, which uses both an adjacency list model as
well as a cached root tree ID, it became obvious that using
the SQLAlchemy ORM modeling to generate the required queries for
various methods related to resource providers was resulting in awkward
and hard-to-reason-about code. Even using the recommended handling of
self-referential tables [1] for adjacency list modeling, the way the
session and querying handling was done in the resource_provider.py
module led to a number of lazy-loading problems and inactive session
errors.

In this starter patch, we tackle the ResourceProvider.get_by_uuid()
method, converting it to use the SQLAlchemy core expression API instead
of an ORM query.

[1] http://docs.sqlalchemy.org/en/latest/orm/self_referential.html

blueprint: de-orm-resource-providers

Change-Id: I2f14afa8fc01b0ec1b7ea3eaa0bf6c459a8681d2
2017-10-09 09:10:08 -07:00
Balazs Gibizer ad33ae5771 use already loaded BDM in instance.create
In I18e7483ec9a484a660e1d306fdc0986e1d5f952b BDM was added to the instance
notifications. In general to add BDM to the payload an exta DB query is
needed. However the BDM is already locaded before the
notify_about_instance_create is called to send the notification. In this cases
loading the BDM again is unnecessary as the already loaded BDM can be reused.

This patch makes sure that notify_about_instance_create is called with the
already loaded BDM.

The remaining instance related versioned notification calls does not have
BDM already loaded.

Change-Id: Ic25de45c18348206f0309da6d4997f4bf336acb2
Closes-Bug: #1718226
2017-10-09 17:57:52 +02:00
Balazs Gibizer 41a0f51341 use already loaded BDM in instance.<action> (2)
I8849ae0f54605e003d5b294ca3d66dcef89d7d27 made it possible for
_get_instance_block_device_info to take a BDM parameter instead of
loading the BDM from the db. This allow us to load the BDM a bit
earlier in the call chain and pass that BDM to the notification calls
too.

The remaining calls of the notify_about_instance_action does not have
the BDM loaded already.

Change-Id: Icc3ffe4037a44f4f323bec2f80d99ca226742e22
Related-Bug: #1718226
2017-10-09 17:50:17 +02:00
Balazs Gibizer c4fadfd4d2 use already loaded BDM in instance.<action>
In I18e7483ec9a484a660e1d306fdc0986e1d5f952b BDM was added to the instance
notifications. In general to add BDM to the payload an exta DB query is
needed. However in some places the BDM is already separately before the
notify_about_instance_action is called to send the notification. In this cases
loading the BDM again is unnecessary as the already loaded BDM can be reused.

This patch makes sure that notify_about_instance_action is called with the
already loaded BDM. There will be subsequent patches to do the same with
other notify calls.

Change-Id: I391554d3904a5a60b921ef4714a1cfd0a64a25c2
Related-Bug: #1718226
2017-10-09 17:50:12 +02:00
Balazs Gibizer 0d4c3cc65b Remove dead code of api.fault notification sending
Based on the description of the notify_on_api_faults config option [1]
and the code that uses it [2] nova sends and api.fault notification
if the nova-api service encounters an unhandle exception.
There is a FaultWrapper class [3] added to the  pipeline of the REST
request which catches every exception and calls the notification sending.

Based on some debugging in devstack this FaultWrapper never catches any
exception. Every REST API method is decorated with expected_errors
decorator [5] which as a last resort translate the unexpected exception
to HTTPInternalServerError. In the wsgi stack the actual REST api call is
guarded with ResourceExceptionHandler context manager [7] which translates
HTTPException to a Fault [8]. Then Fault is catched and translated to
the REST response [7]. This way the exception never propagates back to
the FaultWrapper and therefore the api.fault notification is never emitted.

Based on the git history of the expected_errors decorator this notification
was never emitted for v2.1 API and as the v2.0 API now supported with the
same codebase than v2.1 it is not emitted for v2.0 calls either. As nobody
reported a bug I assume that nobody tried to use this notification for a very
long time. Therefore instead of fixing this bug this patch propses to remove
the dead code.

See a bit more detailed description on the ML [9].

[1] https://github.com/openstack/nova/blob/0aeaa2bce8ad15bc2f28e00b30d688514b992e13/nova/conf/notifications.py#L49
[2] https://github.com/openstack/nova/blob/0aeaa2bce8ad15bc2f28e00b30d688514b992e13/nova/notifications/base.py#L84
[3] https://github.com/openstack/nova/blob/0aeaa2bce8ad15bc2f28e00b30d688514b992e13/nova/api/openstack/__init__.py#L78
[5] https://github.com/openstack/nova/blob/0aeaa2bce8ad15bc2f28e00b30d688514b992e13/nova/api/openstack/extensions.py#L325
[7] https://github.com/openstack/nova/blob/0aeaa2bce8ad15bc2f28e00b30d688514b992e13/nova/api/openstack/wsgi.py#L637
[8] https://github.com/openstack/nova/blob/0aeaa2bce8ad15bc2f28e00b30d688514b992e13/nova/api/openstack/wsgi.py#L418
[9] http://lists.openstack.org/pipermail/openstack-dev/2017-June/118639.html

Change-Id: I608b6ebdc69d31eb2a11ac6479fa4f2e8c20f7d1
Closes-Bug: #1699115
2017-10-09 17:29:40 +02:00
Balazs Gibizer 0ffe03a265 Fix sending legacy instance.update notification
The if_notifications_enabled decorator skips the execution of the
decorated function if the versioned notifications are not configured
to be emitted. The send_instance_update_notification() call was wrongly
decorated with this decorator as it not only sends versioned
notification but also send the legacy compute.instance.update
notification as well. This caused that the legacy instance.update
notification was not emitted when the notification_format config option
was set to unversioned.

As the _send_versioned_instance_update() call already has the decorator
the solution is simply to remove the decorator from the
send_instance_update_notification() call.

Closes-Bug: #1721843
Change-Id: I9904adeb3de60cff4e29f1ab3c95399bbe9ff2e7
2017-10-09 17:20:50 +02:00
Jenkins 664322cae7 Merge "Fix instance_get_by_sort_filters() for multiple sort keys" 2017-10-09 14:59:41 +00:00
Matt Riedemann 3793fd4d1e Fix typo in test_prep_resize_errors_migration
The errors_out_migration_ctxt context manager
sets the Migration object status to 'error', not 'failed'
which is also used in some places in the code. There is no
technical difference between either, they mean essentially
the same thing to the end user, but if we're going to use
them let's be clear in code comments.

Change-Id: Id51f3e2524ae6ee25f8d382070aeed9d666d992d
2017-10-09 10:32:22 -04:00
Eric Fried 0a8f019be0 nova.utils.get_ksa_adapter()
Provide a new method:

nova.utils.get_ksa_adapter(service_type, ks_auth=None, ks_session=None,
                           min_version=None, max_version=None))

...to configure a keystoneauth1 Adapter for a service.  The Adapter, and
its component keystoneauth1 artifacts not passed into the method, are
loaded based on options in the conf group corresponding to the specified
service_type.

The ultimate goal is to replace the various disparate mechanisms used by
different services to do endpoint URL and version discovery.  In Queens,
the original mechanisms will still take precedence, but (other than
[glance]api_servers - see the spec) will be deprecated.  In Rocky, the
deprecated options will be removed.

This change incorporates the above utility into endpoint discovery for
glance and ironic.  Future change sets will do the same for other
services (cinder, neutron, placement).

Change-Id: If625411f40be0ba642baeb02950f568f43673655
Partial-Implements: bp use-ksa-adapter-for-endpoints
Closes-Bug: #1707860
2017-10-09 08:24:40 -05:00
Jenkins 9ed0838da3 Merge "Add 400 as error code for resource class delete" 2017-10-09 10:52:47 +00:00
Jenkins 79ce4bef48 Merge "Set migration object attributes for source/dest during live migrate" 2017-10-07 19:07:46 +00:00
Dan Smith add69c0507 Always put 'uuid' into sort_keys for stable instance lists
If we're listing by sort keys that yield many ambiguous results, we
may exacerbate issues in client pagination because we're not even
bound by insertion order given that we have multiple databases being
queried in parallel. So, even if the client didn't ask for it, throw
'uuid' into the end of sort_keys to provide us a stable ordering. This
was done for the default case by always including 'id' in the default
set of sort_keys, although a user could still break if they request
their own keys.

Note this also removes the recently-added explicit sort in the
test_bug_1689692 case, since we're enforcing a strict ordering with
this patch. Also, mriedem is awesome.

Change-Id: Ida446acb1286a8b215451a5d8d7d23882643ef13
Closes-Bug: #1721791
2017-10-07 07:45:40 -07:00
Dan Smith 00bbc2ffd3 Fix instance_get_by_sort_filters() for multiple sort keys
This method would not actually work for any query where multiple sort
keys were provided. Since it effectively ANDed all of the sort_key > val
conditions in the query, any multi-key sort would exclude a lot of
results.

This fix actually replicates much of the logic from the base
paginate_query() utility method, which properly handles multiple
keys by creating key1>val1 OR (key1=val2 AND key2>=val2) WHERE
clauses necessary for proper ordering.

Change-Id: I3dac96759f7c7f11a0e0e9d86731dd4d22462d33
Partial-Bug: #1721791
2017-10-07 07:45:40 -07:00
Jenkins a347b8099e Merge "Remove 400 as expected error" 2017-10-07 09:14:27 +00:00
Jenkins 51e1638230 Merge "Stop joining on system_metadata when listing instances" 2017-10-07 05:37:47 +00:00
Jenkins c8e2e6ffcc Merge "Refactor duplicate code for looking up the compute node name" 2017-10-07 04:23:27 +00:00
Jenkins b696510ac9 Merge "Add hints to what the Migration attribute values are" 2017-10-07 04:22:42 +00:00
Jenkins 0f5fdde8a0 Merge "Note TrustedFilter deprecation in docs" 2017-10-06 22:58:46 +00:00
Jenkins 353db2d193 Merge "api-ref: note that project_id filter only works with all_tenants" 2017-10-06 17:44:52 +00:00
Jenkins 3924a43bf5 Merge "Add error notification for instance.interface_attach" 2017-10-06 17:09:42 +00:00
Jenkins 8299d29c38 Merge "stabilize test_resize_server_error_and_reschedule_was_failed" 2017-10-06 16:10:08 +00:00
Jenkins ef76319541 Merge "Remove dest node allocations during live migration rollback" 2017-10-06 14:30:19 +00:00
Előd Illés 06231be9ed Add error notification for instance.interface_attach
Change-Id: Idde2e36658d2fd98444fb0780899bfca32dd2d6e
Implements: bp versioned-notification-transformation-queens
2017-10-06 13:45:11 +00:00
Matt Riedemann 7055b5305c Note TrustedFilter deprecation in docs
Change 82f16b88f3 deprecated
the TrustedFilter for removal in Queens, but there is an
entire document about using it which doesn't mention this,
so it's noted here.

Change-Id: I4f772a50cfdbc1f50759c67b234e5c7e29e81100
2017-10-05 18:47:40 -04:00
melanie witt 53f244da12 Make setenv consistent for unit, func, and api-samples
Since ostestr switched to running stestr under the covers, we lost the
old magic setting of the environment variables via .testr.conf for
capturing stderr/stdout and the test timeout. This makes the unit,
functional, and api-samples envs consistent with the py27 env that was
already updated to set those variables.

This also updates the pretty_tox3.sh script to run stestr directly.

Change-Id: I27fa9b7e25c1a1dc921653eec84864423f898a85
2017-10-05 21:45:46 +00:00
Matt Riedemann f1317c016c Blacklist test_extend_attached_volume from cells v1 job
The cells API doesn't route the os-server-external-events API
and this test relies on that working, so we have to blacklist it.

Change-Id: I92e316cb9cfa5d47c415ba06edf45d7de68677f4
Closes-Bug: #1721644
2017-10-05 17:31:05 -04:00
Dan Smith 9868a4d9c1 Pre-create migration object
We need to do this so we can have a migration uuid at the time we
call to scheduler to allocate for the new host. This just does the
plumbing through the RPC layers. The compute-side code can already
tolerate a migration having been already created for things like
live migration, so we just have to plumb it through.

Related to blueprint migration-allocations

Change-Id: I6bc6d28655368084f08fed9c4f56a285b7063338
2017-10-05 13:49:15 -07:00
Jenkins ec4e970412 Merge "fix unstable shelve offload functional tests" 2017-10-05 19:13:11 +00:00
Jenkins 54d8312347 Merge "Don't shell out to mkdir, use ensure_tree()" 2017-10-05 18:14:10 +00:00
Jenkins 49ffcf3a8d Merge "Update RT aggregate map less frequently" 2017-10-05 18:13:35 +00:00
Jenkins c6cce9b5f9 Merge "Add attachment_get call to volume/cinder_api" 2017-10-05 16:54:45 +00:00
Balazs Gibizer b5dca17f74 fix unstable shelve offload functional tests
The functional tests that are shelved offloaded instances and
asserted that the resource allocation of the instance are
freed were unstable. These tests only waited for the instance
state to become SHELVED_OFFLOADED before checked the allocations.
However the compute manager sets the instance state to
SHELVED_OFFLOADED before deleting the allocations[1]. Therefore these
tests were racy.

With this patch the test will wait not only for the instance status to
change but also for the instance host to be nulled as that happens
after the resources are freed.

[1] https://github.com/openstack/nova/blob/e4f89ed5dd4259188d020749fa8fb1c77be2c03a/nova/compute/manager.py#L4502-L4521

Change-Id: Ibb90571907cafcb649284e4ea30810a307f1737e
Closes-Bug: #1721514
2017-10-05 17:25:59 +02:00
Jenkins e4f89ed5dd Merge "Add instance.interface_detach notification" 2017-10-05 11:30:31 +00:00