4312 Commits

Author SHA1 Message Date
Jenkins
47ea0cdee8 Merge "Typo error allocations.yaml" 2016-11-22 07:47:09 +00:00
Diana Clarke
07fbac6db7 Database poison note
Add a few tips for folks that encounter database poison exceptions.

Change-Id: Ic54d9d2fdd100e20e020fb7944f1f7f16be82db0
Related-Bug: #1568414
2016-11-18 11:09:53 -05:00
Jenkins
bf7d70793f Merge "conf: Remove extraneous whitespace" 2016-11-17 14:03:55 +00:00
Jenkins
f5a220ec3d Merge "Add the initial documentation for the placement API" 2016-11-16 12:11:58 +00:00
Jenkins
02b3c7421a Merge "[placement] Enforce min_unit, max_unit and step_size" 2016-11-16 11:42:07 +00:00
Jenkins
dd0cd8bd6a Merge "Placement api: 404 response do not indicate what was not found" 2016-11-16 11:41:06 +00:00
pangliye
7eb0987d6c Typo error allocations.yaml
Change-Id: Id3ce395785963bf9ff015a629f61a296fa343fcd
2016-11-16 18:59:46 +08:00
Jenkins
26ad102b9b Merge "Replace admin check with policy check in placement API" 2016-11-15 17:53:52 +00:00
Chris Dent
291e85a326 [placement] Enforce min_unit, max_unit and step_size
Add support for checking min_unit, max_unit and step_size when
making allocations to the placement API. When the constraints are
violated a new exception InvalidAllocationConstraintsViolated is
raised.

Change-Id: I18596a3c0f2b0049aaccd0f3e73aef90b684c4a8
Closes-Bug: #1623545
2016-11-14 20:04:02 +00:00
Matt Riedemann
bc29704f87 Add the initial documentation for the placement API
This is the initial set of docs for the placement API
service introduced in the Newton release.

We still have to flesh out the API reference in detail
but this gets us started.

The deployment steps are taken from how devstack does
this today.

Change-Id: Ic2436d92a7cefaeb1ae67ed878da968444f2f18d
2016-11-11 17:21:50 -05:00
Jenkins
dc1101c750 Merge "[placement] add a placement_aggregates table to api_db" 2016-11-11 21:39:18 +00:00
Jenkins
e7df53a867 Merge "EventReporterStub" 2016-11-10 15:54:38 +00:00
Jenkins
2ff3157d56 Merge "Change database poison warning to an exception" 2016-11-10 15:24:05 +00:00
Jenkins
c6450c74cd Merge "encryptors: Workaround mangled passphrases" 2016-11-10 15:21:43 +00:00
Diana Clarke
88cfde277e Change database poison warning to an exception
The following warning appears in the unit test logs a number of times.

    "UserWarning: This test uses methods that set internal oslo_db
state, but it does not claim to use the database. This will conflict
with the setup of tests that do use the database and cause failures
later."

Note that this warning is only emitted once per unit test worker, so new
offenders will show up in the logs each time you fix a test until they
are all gone.

This patch is intended to be merged after all the existing warnings are
addressed by other patches in this series:

  https://review.openstack.org/#/q/topic:bug/1568414

Change-Id: I91909a356187bac70fa2fa920cebf3888410ae01
Closes-Bug: #1568414
2016-11-10 14:02:10 +00:00
Pushkar Umaranikar
7c0bdd52a3 Placement api: 404 response do not indicate what was not found
Add informative messages to the 404 error response from
nova/objects/resource_provider.py

For the method _update_inventory_in_db() from resource_provider.py,
gabbi test validation is not added since it is not being used and
from the placement API you create an inventory but then call
set_inventory or add_inventory on a resource_provider.

Similar change, i.e. adding informative messages to 404 error can be
done for api tests from inventory.yaml and usage.yaml

It includes adding informative logging in code for 404 exceptions and
adding gabbi tests for those.
This can be done in follow up patch.

Change-Id: If53f84ac5f7521e9926b97bdcce3cf77ec5b4ffd
Closes-Bug: #1634115
2016-11-09 21:11:07 +00:00
Jenkins
41447556e4 Merge "[placement] Add support for a version_handler decorator" 2016-11-09 03:18:16 +00:00
Chris Dent
320f60f28b [placement] add a placement_aggregates table to api_db
In order to facilitate a future extraction of the placement service
we want to record the association between a resource provider and an
arbitrary aggregate uuid in its own table.

A PlacementAggregate model is joined from ResourceProvider via
ResourceProviderAggregate. Note that this structure is used so we can
join on ids instead of strings (the uuids). A direct mapping between
ResourceProvider uuid and Aggregate uuid was mooted earlier in the year
but was determined to be suboptimal.

The name 'placement_aggregates' is used as the least problematic of
several choices after discussion amongst several parties.

The data will be used by the forthcoming get_ and set_aggregates
methods on the ResourceProvider object.

Change-Id: Id0355cb022f68e962af306ff04cf724d22b68d19
Partially-Implements: blueprint generic-resource-pools-ocata
2016-11-08 16:09:56 +00:00
Jenkins
d1c5065493 Merge "placement: raise exc when resource class not found" 2016-11-04 22:00:40 +00:00
Stephen Finucane
85e7d91e08 conf: Remove extraneous whitespace
Per the conventions seen in other files.

Change-Id: I84b15f0eeddfd4d654aea9b5386ae3d90faafabf
Implements: bp centralize-config-options-ocata
2016-11-04 10:40:20 +00:00
Diana Clarke
53fe742087 EventReporterStub
A number of tests in test_compute_mgr.py patch the event reporter to
prevent database poison warnings but otherwise don't assert on the event
reporter behaviour. Replace those individual mocks with a fixture that
stubs out the event reporter in the test setUp.

Change-Id: I57233259065d887b38a79850a05177fcbbdfb8c3
Related-Bug: #1568414
2016-11-03 22:17:52 -04:00
Jay Pipes
bc39bcda4c placement: raise exc when resource class not found
The ResourceProvider.set_inventory() method was not raising NotFound
when an Inventory object in the supplied InventoryList object was using
a resource class that did not exist in the resource class cache. This
patch fixes that by having the string_from_id() and id_from_string()
methods of the resource class cache raise ResourceClassNotFound instead
of returning None. We raise specific ResourceClassNotFound and
InventoryWithResourceClassNotFound exception subclasses to differentiate
in the inventory API handler between an unknown resource class and a
known resource class that doesn't exist in a given resource provider's
inventory.

We return a 400 Not Found when InventoryWithResourceClassNotFound is
raised on updating a single inventory, but return a 409 Conflict when
InventoryWithResourceClassNotFound is raised on updating a set of
inventory records since in the latter scenario, it represents a race
condition that frankly should not occur.

Change-Id: I350b02dcdbaa9d30d885cd085f60daa6b53a7745
2016-11-03 11:48:53 -04:00
Lee Yarwood
5a3ef8b40f encryptors: Workaround mangled passphrases
Prior to Ib563b0ea the passphrase used by CryptsetupEncryptor and
LuksEncryptor had any leading zeros per hexadecimal digit removed, for
example 0x04 or 04 would turn into 0x4 or 4. As a result any volume
encrypted prior to the release of Newton used a modified passphrase that
was different to that stored by the key manager being used in the
environment.

To correct this for LuksEncryptor volumes permission denied errors are
now caught when attempting to open a volume. A second attempt to open
the volume is then made using a mangled passphrase. If successful the
correct passphrase is then added to the volume before the mangled
passphrase is finally removed. This workaround can be removed in a
future release once it is safe to assume that all LuksEncryptor volumes
have had any mangled passphrases replaced in this way.

This isn't possible for CryptsetupEncryptor volumes as the plain mode
used by cryptsetup does not provide a way for adding and removing keys.
As such on a permission denied error a second attempt is made to open
the volume using a mangled passphrase. Unlike the above workaround this
cannot be removed in a future release.

Change-Id: I7096463c5eba951dd6322ee6965435e877ca0371
Partial-bug: #1633518
2016-11-02 20:03:41 +00:00
Andrew Laski
7777ec9a14 Replace admin check with policy check in placement API
This sets up a basic framework for policy checking in the placement API
and replaces the current admin check.

There are some limitations here based on oslo.policy limitations. It
turns out that policy rule defaults can only be registered if a policy
file is also used. Since we don't have immediate plans for a placement
policy file the issue is avoided by loading the necessary rule when
policy.Enforcer is initialized. There is also no support for generating
policy files using the oslopolicy CLI scripts. This can all be addressed
later when we determine a path for separating placement policy from Nova
or merging it together.

Although there is an existing nova.policy the changes for placement
policy are implemented in nova.api.openstack.placement.policy to
ease any later extraction that may happen. This is straightforward
because the placement policy code doesn't use any code from
nova.policy.

Co-Authored-By: Chris Dent <cdent@anticdent.org>
Change-Id: Ia62158e0eed50a34114718ee724b038f577c7e87
Partially-Implements: bp placement-api-policy-authz
2016-10-31 12:46:39 +00:00
Takashi NATSUME
f653f8b52e Fix import statement order
Fix import statement order to comply with
OpenStack Style Guidelines(*1).

*1: http://docs.openstack.org/developer/hacking/#import-order-template

TrivialFix
Change-Id: I8ded09c14396a46f9d0f8f565d1294b179ce09bc
2016-10-31 21:42:42 +09:00
Jenkins
b83e47c756 Merge "Removal of tests with different result depending on testing env" 2016-10-28 09:06:00 +00:00
Matt Riedemann
8efb8ca4be Make build_requests.instance MediumText
The build_requests.instance column is a serialized
instance object, and the instances.user_data column
is MediumText, so the build_requests.instance column
itself needs to be at least MediumText in size for MySQL.

Change-Id: I7d65df37c02750593037744543ad15e5bc64e913
Closes-Bug: #1635446
2016-10-26 06:27:07 -04:00
Jenkins
9689bf8813 Merge "Correct bug in microversion headers in placement" 2016-10-21 14:34:06 +00:00
Jenkins
379a9e9051 Merge "placement: change resource class to a StringField" 2016-10-21 14:31:57 +00:00
Takashi NATSUME
5fec8c9d40 Add swap volume notifications (error)
Add the following notification when swapping volumes.

* 'instance.volume_swap.error'

Change-Id: I90d4ffcb2ffc318de2365a655b5fde8bb6c05ff2
Implements: blueprint add-swap-volume-notifications
2016-10-20 13:50:44 +00:00
Chris Dent
2ccf5fc6b2 [placement] Add support for a version_handler decorator
Provide a decorator that allows Placement API handlers to
express a microversion window within which that method should be
used. This makes it possible to define N different methods (with the
same name) to present different behaviors dependent on what
microversion is requested by the user-agent.

If there is no match between a valid requested microversion and
available versioned handlers a 404 response is returned.

The mechanism for managing the versioned handlers is borrowed
from the compute api but adjusted to allow for the fact that
placement handlers are module level functions. Some code is
borrowed from twisted to get fully qualified names of methods for
the VERSION_METHODS dictionary.

Tests are added which validate that versioned handlers do not
intersect. In the rest of nova this is done at runtime, but
in the placement context this isn't necessary. Doing it at testime
is sufficient. Since there are currently no versioned handlers
in addition to the faked tests of the intersection handling I
also manually forced some tests with real handlers, just to be
sure.

Change-Id: I713c139ee12bb7f5301edd85951f8960fda84ac3
2016-10-19 16:19:11 +00:00
Jenkins
6a30087281 Merge "conf: Group scheduler options" 2016-10-18 13:29:33 +00:00
Claudiu Belu
1178d82670 compute: fixes python 3 related unit tests
Fixes volume related unit tests.
Fixes non-sortable None items.
Fixes __getattr__ infinite recursion.
Fixes is_dict_like method. Dicts in python 3.4 do not
have the 'has_key' method.

Partially Implements: blueprint goal-python35

Change-Id: I97efc09f7657436f706b08e0b2795f0e59ac1dcd
2016-10-18 07:07:43 +00:00
Jenkins
819b3b415e Merge "Cleanup some redundant USES_DB_SELF usage" 2016-10-18 02:34:45 +00:00
Jay Pipes
dd009ffa24 Correct bug in microversion headers in placement
Found a small bug in the handling of a 406 error by the placement API's
microversion handling code that only appeared when more than one
microversion was used.

Change-Id: I8562e9ce962352033e43a3b993f8b8ba6f211fd4
2016-10-14 14:07:30 -04:00
Michal
f0071950b2 Removal of tests with different result depending on testing env
Remove gabbi tests which are reporting success or failure depending
on the environment they are ran in as this was misleading.

Change-Id: Ifb06b353e4264f4276ebb294a089c4fede74067f
2016-10-13 19:27:08 +02:00
Jay Pipes
6f95f07ff5 placement: change resource class to a StringField
This patch modifies the fields.ResourceClass field type from an
EnumField to a StringField. This keeps the over-the-wire format of the
field backwards-compatible while allowing us to add non-standardized,
custom resource classes to the new resource_classes database table.

We change all locations of fields.ResourceClass.index() and
fields.ResourceClass.from_index() to use the ResourceClassCache object
added in the previous patch in this series and add some check logic in
Inventory and Allocation object's obj_make_compatible() methods to
ensure backversioned objects requesting or sending with a resource class
string different than the set of strings in the ResourceClass field at
the time of this patch raises a ValueError.

Change-Id: I2c1d4ae277ba25791c426e1c638dca1b1cb207a4
blueprint: custom-resource-classes
2016-10-12 17:24:09 -04:00
Jenkins
badf59cd3f Merge "Add quota related tables to the api database." 2016-10-12 21:21:28 +00:00
Gábor Antal
75f7a2f29e Use more specific asserts in tests
Use asserts with more specific assert methods, e.g.: from
assertTrue(sth == None) to assertIsNone(*),
assertTrue(isinstance(inst, type)) to assertIsInstace(inst, type) or
assertTrue(not sth) to assertFalse(sth).

This change ensures a better description will be shown on fail. This is
the recommended way to use assertions provided by testtools.

Change-Id: Ia4a34e0145176e077bbf7e9ed6f69d815c6ed840
Co-authored-by: Stephen Finucane <sfinucan@redhat.com>
2016-10-12 11:12:08 +01:00
Mark Doffman
650ff9387c Add quota related tables to the api database.
Quotas are required to exist in the API database as we need to enforce
quotas across cells.

blueprint cells-quota-api-db

Change-Id: I52fd680eaa4880b06f7f8d4bd1bb74920e73195d
2016-10-12 07:40:00 +00:00
Jenkins
265bfba54a Merge "placement: add new resource_classes table" 2016-10-11 22:35:36 +00:00
Jenkins
30c5e28712 Merge "Add swap volume notifications (start, end)" 2016-10-11 17:56:06 +00:00
Jay Pipes
634b59c73a placement: add new resource_classes table
We will store custom resource classes in the new resource_classes table.
These custom resource classes represent non-standardized resource
classes. Followup patches add the plumbing to handle existing
standardized classes currently using the fields.ResourceClass field type
and to perform CRUD operations against a /resource-classes REST API
endpoint.

Change-Id: I60ea0dcb392c1b82fead4b859fc7ed6b32d4bda0
blueprint: custom-resource-classes
2016-10-11 12:30:44 -04:00
Takashi NATSUME
ab8382ffa1 Add swap volume notifications (start, end)
Add the following notifications when swapping volumes.

* 'instance.volume_swap.start'
* 'instance.volume_swap.end'

A subsequent patch will add 'instance.volume_swap.error'.

Change-Id: Ic4d9d25bdc611221157e4663817e918b8d667ce9
Implements: blueprint add-swap-volume-notifications
2016-10-11 19:17:23 +09:00
Takashi NATSUME
5bcab383ba Add a hacking rule for string interpolation at logging
String interpolation should be delayed to be handled
by the logging code, rather than being done
at the point of the logging call.
So add the following hacking rule for it.

- [N354] String interpolation should be delayed at logging calls.

See the oslo i18n guideline.

* http://docs.openstack.org/developer/oslo.i18n/guidelines.html

Change-Id: Ief6d3ee3539c0857098fffdb7acfeec3e0fed6eb
Closes-Bug: #1596829
2016-10-11 08:39:48 +00:00
Gary Kotton
c1579af1aa Tests: fix a typo
TrivialFix

Change-Id: I83ea75257d5b900a37f024fe29427d33c4f2b17e
2016-10-10 00:45:11 -07:00
Alexis Lee
740b90c96c conf: Group scheduler options
Move all scheduler options into their one of two groups. Many of the
options are simply renamed to remove their 'scheduler_' prefix, with
some exceptions:

* scheduler_default_filters -> enabled_filters
* scheduler_baremetal_default_filters -> baremetal_enabled_filters
* scheduler_driver_task_period -> periodic_task_interval
* scheduler_tracks_instance_changes -> track_instance_changes

Change-Id: I3f48e52815e80c99612bcd10cb53331a8c995fc3
Co-Authored-By: Stephen Finucane <sfinucan@redhat.com>
Implements: blueprint centralize-config-options-ocata
2016-10-07 14:36:21 +01:00
Jenkins
fb0ed6dc45 Merge "[placement] reorder middleware to correct logging context" 2016-10-07 12:11:29 +00:00
Jenkins
90363b02f4 Merge "[placement] Allow both /placement and /placement/ to work" 2016-10-07 12:10:49 +00:00
Jenkins
d22488d6e1 Merge "[placement] ensure that allow headers are native strings" 2016-10-07 12:09:26 +00:00