11321 Commits

Author SHA1 Message Date
Chris Dent
07d7749cff Implement a more complex nested-perfload topology
This changes gabbits/nested-perfload.yaml to create a tree of
providers based on one of the compute nodes in the NUMANetworkFixture
used in the functional tests. For the time being only one type of
compute node is created (of which there will be 1000 instances).
Room is left for future expansion as requirements expand.

The resulting hierarchy has 7 resource providers.

The allocation candidates query is:

GET /allocation_candidates?
    resources=DISK_GB:10&
    required=COMPUTE_VOLUME_MULTI_ATTACH&
    resources_COMPUTE=VCPU:1,MEMORY_MB:256&
    required_COMPUTE=CUSTOM_FOO&
    resources_FPGA=FPGA:1&
    group_policy=none&
    same_subtree=_COMPUTE,_FPGA

This is a step in the right direction but is not yet a complete
exercising of all the nested functionality. It is, however, more
complex than prior, notably testing 'same_subtree'. We should
continue to iterate to get it doing more.

Change-Id: I67d8091b464cd7b875b37766f52818a5a2faa780
Story: 2005443
Task: 35669
2019-08-06 09:18:39 +01:00
Chris Dent
7464ff6e24 Run nested-perfload parallel correctly
While experimenting with expanding the nested perfload tests,
it became clear that the call to parallel was not working as
expected because the documents were misread. With help from
Tetsuro the correct incantation was determined so that we
use 50% of available CPUs.

This should leave some space for the database and the web
server.

Subsequent patches will add a more complicated nested structure.

Co-Authored-By: Tetsuro Nakamura <tetsuro.nakamura.bc@hco.ntt.co.jp>
Change-Id: Ie4809abc31212711b96f69e5f291104ae761059e
2019-08-06 09:14:58 +01:00
Zuul
b12cba973d Merge "Use expanding bindparam in provider_ids_from_rp_ids in_" 2019-08-02 17:38:44 +00:00
Zuul
089029e92e Merge "Use __slots__ in commonly used objects" 2019-08-02 17:38:43 +00:00
Chris Dent
d4d9457aa1 Use expanding bindparam in provider_ids_from_rp_ids in_
This was explored as part of discussion with zzzeek on various
ways to make a statement with a large in_ be more performant.

Batching the queries by chunking rp_ids did not help, but an
expanding bindparam did: it makes the surrounding method about
50% faster [1].

bindparam expanding was added in sqlalchemy 1.2.0 so we bump
the requirements here to the latest 1.2.x bugfix release,
1.2.19.

[1] With the caveat that profiling and benchmarking are very
different things, and in this case it is profiling results
which are being analysed.

Change-Id: Ic4e0cdd87f8f2d76b921059ac4bf16a838913abf
2019-08-02 15:25:30 +01:00
Chris Dent
5d3243f4b9 Use __slots__ in commonly used objects
When making a nested provider GET /allocation_candidates request
that returns around 6500 providers in the providers summary section,
we make ~22000 ResourceProvider and ProviderSummary objects, 7500
AllocationRequest objects and 30000 ProviderSummaryResource objects.

In aggregate, creating and accessing these objects contributes a
measurable cpu time cost. Using __slots__ [1] can speed up attribute
access (I measured it, it does), so lets use it for the common
objects. There's no evidence (yet) of other objects being an issue
so we won't do this wholesale.

A unit test is updated to change a mock from a public ResourceProvider
method (set_aggregates) to a private function (_set_aggregates)
because one of the limitations of __slots__ is it makes the
slotted objects difficult to mock. In this case the test is still
testing the same thing.

Subsequent patches will explore why we need 22000 ProviderSummary
objects when we're only producing 6500 resulting summaries to see
if there is a cleanup that can be done there.

[1] https://docs.python.org/3/reference/datamodel.html#slots

Change-Id: I4acb16d13976d64d47f798ebbec626a73b79b4f5
2019-08-02 15:17:58 +01:00
Chris Dent
8626b6517b Remove ProviderIds namedtuple
It turns out that all the callers of methods that return ProviderIds
access the data using attributes that are already present on the object
provided by a sql alchemy RowProxy object (which is the result of
iterating a ResultProxy object, returned by sqla.execute()). Creating
a namedtuple is redundant and adds some processing cost [1].

However, the AnchorIds namedtuple used in the same file _is_ necessary
because it provides a hashable type required by the set that wraps
the collection of AnchorIds.

The other user of namedtuple, RPCandidate, in
placement/objects/rp_candidates.py has a specific interface for which
a namedtuple is correct.

[1] provider_ids_from_rp_ids was identified as being a major contributor
when doing performance profiling. Most of the cost is executing with the
database, but the tuple creation is a factor.

Change-Id: I1e1522eae7b4360cf57c34164612ae228fad14a3
2019-08-01 16:48:02 -05:00
Chris Dent
d04168088c Bump os-traits minimum to 0.16.0
os-traits 0.16.0 was just released, adding 3 standard traits.
Require it.

Change-Id: I51f2a77b0f21c6145457bb33fe4db931edca4c99
2019-08-01 10:05:15 +01:00
pengyuesheng
835081ac36 Blacklist sphinx 2.1.0 (autodoc bug)
See https://github.com/sphinx-doc/sphinx/issues/6440 for upstream details

Change-Id: I2809c6be60ac102b40c942483a6cdbc0d113117f
2019-07-31 16:42:51 +08:00
Zuul
541052ad5e Merge "Extra gabbi tests for same_subtree" 2019-07-31 04:42:42 +00:00
Zuul
fe6ec89020 Merge "Run 'tempest-ipv6-only' job in gate" 2019-07-30 16:52:03 +00:00
Eric Fried
3b484c80d5 Extra gabbi tests for same_subtree
This is a followon for test gaps in the same_subtree patch [1].

[1] https://review.opendev.org/#/c/668376/8/placement/tests/functional/gabbits/granular-same-subtree.yaml

Change-Id: I82cf1aec44e251b30295b6119949a5995c0b6e3f
2019-07-30 09:43:48 -05:00
Zuul
2f56f379a5 Merge "Use integrated-gate-placement zuul template" 2019-07-25 20:10:27 +00:00
Chris Dent
b1a7338d2f Use integrated-gate-placement zuul template
The integrated-gate-placement adds the tempest-integrated-placement
and grenade-py3 jobs. tempest-integrated-placement runs a subset of
tempest tests which are relevant for placement, e.g. it does not
run keystone tests.

The integrated-gate-py3 template is replaced by this change. It
specified the tempest-full-py3, meaning many tests not relevant
to placement were run.

See the depends-on for more information on the rationale.

Depends-On: https://review.opendev.org/669309
Change-Id: I509ded97085fbae5a0cc55fe66f6e30e638b72bc
2019-07-25 16:18:38 +01:00
Chris Dent
b09f2f917f Make a TraitCache similar to ResourceClassCache
The Trait and ResourceClass db objects have the same essential
structure and are used throughout the code in similar ways:

* turn a name into an id
* turn an id into a name
* get an unfiltered list of names
* make a mapping of ids to names

In I409a5e819a72d64e66ee390e4528da0c503d8d05 we made the resource
class cache request specific. Doing that work made it pretty clear
we could have a similar cache for traits and as a result visit the
traits db fewer times per request.

The implementation is straightforward: make an _AttributeCache super
class that is a parent to ResourceClassCache. Create TraitCache as
a sibling. The sole difference is the table used for the data authority
and the exception raised when an attribute is not found.

The new super class has been refactored to use private attributes and
methods.

A 'get_all' method is added to the cache to list the full collection
of dicts it contains. That can be be directly transformed into Trait
and ResourceClass objects. The order of the results of this method
are not predictable, and sorting them would add cost for no benefit,
so gabbi tests which had previously relied on the ordered of returned
resource classes have been removed.

From the API, listing traits and resource classes (without filters) now
uses the cache instead of going to the db. Where filters (in traits) are
required, the db is accessed.

The research_context turns lists of trait names into id, name maps for
required and forbidden traits.

Further, anywhere the traits table was joined to create a name of an id,
the cache is used instead. This allows to drop some joins and operate
fully in-process and in-RAM. No additional loops are added to make this
happen: the translation is done in existing loops.

The upshot of these changes is that unless there is a write operation on
a trait or resource class, both tables are scanned at most once in any
request. And when they are scanned it is to list their entire contents.

As noted in the _AttributeCache docstring there are restrictions
on what kinds of entities can use the cache and some necessary
precautions.

Change-Id: Ia19ea2b4ecdde25323579edf60ad6269d05e75a2
2019-07-24 11:23:50 +01:00
Zuul
18c3ebc008 Merge "Further simplify microversion utils" 2019-07-23 18:52:10 +00:00
Zuul
0fe26e363c Merge "Simplify placement.microversion:_fully_qualified_name" 2019-07-23 16:22:32 +00:00
Zuul
d08817bb5a Merge "Update api-ref to point to API-SIG microversion spec" 2019-07-23 16:22:31 +00:00
Eric Fried
7efcb2e7f1 Further simplify microversion utils
Following on from [1]:
- Since we're only ever calling _fully_qualified_name with module-level
  functions, remove the ability to call it with a class (forcing such
  usages to either use functions or modify this util).
- Consolidate a redundant invocation of _fully_qualified_name from
  version_handler.

[1] Id8f96801116818dda6c68c301619aee185e8fbff

Change-Id: I205a7fd338a0db420b891341c3c40b10f3199fd3
2019-07-23 08:57:58 -05:00
Zuul
885012cb64 Merge "Update api-ref location" 2019-07-23 12:23:33 +00:00
Zuul
7266ce87f6 Merge "Make placement testing easier on osx" 2019-07-23 12:23:32 +00:00
Chris Dent
99b107fb5a Update api-ref to point to API-SIG microversion spec
The docs had been using a reference within the nova docs, which
is similar to, but less generic than the API-SIG doc.

Change-Id: I7087e311209716a2907575573b9c018c352ce63d
2019-07-23 11:33:05 +01:00
Andreas Jaeger
7b3c179fe4 Update api-ref location
The api documentation is now published on docs.openstack.org instead
of developer.openstack.org. Update all links that are changed to the
new location.

Note that redirects will be set up as well but let's point now to the
new location.

For details, see:
http://lists.openstack.org/pipermail/openstack-discuss/2019-July/007828.html

Change-Id: Iccddd4356b5d7c28977ad954654d0875972dae97
2019-07-22 19:17:01 +02:00
Ghanshyam Mann
8eedcfcea5 Run 'tempest-ipv6-only' job in gate
As part of Train community goal 'Support IPv6-Only Deployments and Testing'[1],
Tempest has defined the new job 'tempest-ipv6-only'(adding
in Depends-On patch) which will deploy services on IPv6 and run smoke
tests and IPv6 related tests present in Tempest.

This job will be part of Nova, Neutron, Cinder, Keystone, Glance, Swift
gate.

Verification structure will be:
- 'devstack-IPv6' deploy the service on IPv6
- 'devstack-tempest-ipv6' run will verify the IPv6-only setting and listen address
- 'tempest-ipv6-only' will run the smoke + IPv6 related test case.

This commit adds the new job 'tempest-ipv6-only' run on gate.

Story: #2005477
Task: #35919

Depends-On: https://review.opendev.org/#/c/671231/

[1] https://governance.openstack.org/tc/goals/train/ipv6-support-and-testing.html

Change-Id: Iff0e8d91048a4644cca4fd9242535b940b721d3b
2019-07-20 17:54:00 +00:00
Zuul
9e8040bf0c Merge "Move rc_cache onto RequestContext" 2019-07-19 00:26:22 +00:00
Chris Dent
a24868fd8b Bump os-resource-classes requirements
os-resource-classes 0.5.0 was recently released and upper
constraints were bumped. We have decided to always pin placement
to the latest versions of os-resource-classes and os-traits.
This patch makes it so, again.

Change-Id: Idd4920885b10f0b21b2b67d9526f1048b06f7db5
2019-07-18 13:26:12 +01:00
Chris Dent
2fc321aea3 Move rc_cache onto RequestContext
Experimentation led to the discovery (as described in the story
noted below) that the global RC_CACHE is not safe in a multi-process
environment, which is common for a web service designed to scale
horizontally.

In rare circumstances it is possible for a custom resource class
to be deleted in one process but still appear to exist in another.
For many situations this wouldn't really matter, but there are
cases, even more rare, where it would be possible to write allocations
or resource provider inventory using the wrong resource class
id.

On the related story, a variety of options were discussed to fix
this. Reading through the code this one (which is option 2) was
the only one that proved workable in a relatively straightforward
fashion: Have a per request cache.

To that end, when a RequestContext is created (per request) the
resource class table is scanned to create a cache. Because the
context is local to this request, we no longer need to do any
locking around the cache, either when we create it or when we clear
it: The caller is linear.

The cost of this is that now every single request starts with a
scan of the resource class table. This isn't horrible: if we
had no cache at all we'd be reading rows from that table multiple
times throughout any request (read or write).

We should probably do some performance analysis to see what the
impact of this might be. The perfload jobs may be able to give
a limited sense of what the impact is, but profiling will be
required for accuracy.

It is the case that the functional tests seem a bit slower because
of that additional db query.

Change-Id: I409a5e819a72d64e66ee390e4528da0c503d8d05
Story: 2006232
Task: 35833
2019-07-18 11:04:48 +01:00
Chris Dent
baaaff17b5 Make placement testing easier on osx
Placement can run just fine on OSX but running the tests can
be a bit cumbersome since dev libraries for ssl, postresql,
and mysql are required (directly or indirectly) by
test-requirements.txt, even though for non-gate testing we don't
usually need them, and dealing with dynamic libraries is a
frequent source of pain and discomfort on OSX.

This change says "don't import SQL drivers for mysql and postgresql
when testing on darwin".

Change-Id: Ic0ff55f00e0312251207fd079cf7b7e98d950c87
2019-07-17 13:24:44 +01:00
Zuul
3ba36fb717 Merge "Add Python 3 Train unit tests" 2019-07-16 09:42:51 +00:00
Zuul
482d80a5fb Merge "Follow up fix for same_subtree documentation" 2019-07-15 08:38:55 +00:00
Zuul
a6ada10049 Merge "api-ref: Document generations" 2019-07-12 17:25:57 +00:00
Chris Dent
d2b452d7f5 Simplify placement.microversion:_fully_qualified_name
_fully_qualified_name was copied from Twisted. The original
version does more than Placement needs. We only need to
handle module-level classes and functions (and really only
functions). No nested of those, nor object methods in any
form.

This is because we only use the method for finding the
right microversioned handler of a method with the same
name and placement HTTP handlers are universally functions.

The previous version of the method had code that was never
called. Here, that dead code is removed and the remainder
is simplified.

If it is called incorrectly there will be an (intentionally)
untrapped TypeError during running of the tests.

N.B.: This was discovered while reviewing coverage data.

Change-Id: Id8f96801116818dda6c68c301619aee185e8fbff
2019-07-12 14:27:41 +01:00
Zuul
b9cbda42a1 Merge "Doc same_subtree queryparam" 2019-07-11 23:04:42 +00:00
Zuul
bf4e02478a Merge "Add placement.query.missing_value in api-ref" 2019-07-11 23:04:39 +00:00
Eric Fried
a09defd661 api-ref: Document generations
The API reference for POST /allocations [1] and PUT
/allocations/{consumer_uuid} [2] specifically mentions that you can get
a 409 on provider/inventory conflict. In microversion 1.28, it also
became possible to get a 409 on an allocation (consumer generation)
conflict.

In the process of adding that information, it became evident that we
weren't doing a good job explaining the whole generation thing in
general, so this commit also adds a descriptive section to the front
matter of the API reference.

Links are included from the updated descriptions for the two affected
allocations operations. Future commits can add links from other
appropriate sections of the reference (e.g. the parameters.yaml entries
for resource provider and consumer generation fields). Future commits
could also enhance the descriptions of error codes for other operations
to (at least) the level of detail at which these have ended up.

[1] https://developer.openstack.org/api-ref/placement/?expanded=manage-allocations-detail#manage-allocations
[2] https://developer.openstack.org/api-ref/placement/?expanded=update-allocations-detail#update-allocations

Change-Id: I42e76785e0fe456b107fe843dbb242f2c5f5b9f7
Story: #2006180
Task: #35705
2019-07-11 16:31:28 -05:00
Zuul
49f28a93cc Merge "Add query.duplicate_key and .bad_value in api-ref" 2019-07-11 08:28:55 +00:00
Tetsuro Nakamura
4ae8ffea1e Add placement.query.missing_value in api-ref
This commit documents a new error code placement.query.missing_value,
which was added via [1] but missed in the summary table in the API
reference [2].

Story: #2006194
Task: #35776

[1] 8395e3f099022d8506ed5e6624582ec03e46c3b9
[2] https://developer.openstack.org/api-ref/placement/#errors

Change-Id: I36ee636946c2e8b2c4b07b0449460bd31960f637
2019-07-11 06:25:54 +00:00
Corey Bryant
7858375439 Add Python 3 Train unit tests
This is a mechanically generated patch to ensure unit testing is in place
for all of the Tested Runtimes for Train.

See the Train python3-updates goal document for details:
https://governance.openstack.org/tc/goals/train/python3-updates.html

Change-Id: I2ef60794a2606a7d7abfd413c6ba50689c52e67b
Story: #2005924
Task: #34236
2019-07-10 21:09:52 +00:00
Zuul
83facc1947 Merge "Add a test for granular member_of not flowing down" 2019-07-10 07:23:35 +00:00
Zuul
34c1dd88b3 Merge "Support same_subtree queryparam" 2019-07-09 22:49:26 +00:00
Tetsuro Nakamura
3f786431a4 Doc same_subtree queryparam
This patch adds usage documents for the new `same_subtree` queryparam
in `Modeling with Provider Trees` page.

Change-Id: I52a48692aa7069eb16ce4f078cc671fe38728729
Story: 2005575
Task: 30784
2019-07-09 11:50:49 +00:00
Eric Fried
328f7a3a36 Add query.duplicate_key and .bad_value in api-ref
This commit documents new error codes placement.query.duplicate_key and
placement.query.bad_value, which were were added via [1] but missed in
the summary table in the API reference [2].

Story: #2006194
Task: #35776

[1] I76cad83248920fa71da122711f1f763c4ebdb1ba
[2] https://developer.openstack.org/api-ref/placement/#errors

Change-Id: I024eaa38c6574f5847d585c83d527e3374031105
2019-07-09 10:32:45 +00:00
Tetsuro Nakamura
efaa36443f Follow up fix for same_subtree documentation
This patch fixes incorrect usages of fixed articles changing them to
indefinite articles in same_subtree documentation.

Change-Id: I6ba2e2f13400b4c2ae9a44cad7a1fc9a9e39b41d
Story: 2005575
Task: 30784
2019-07-09 10:23:54 +00:00
Tetsuro Nakamura
23300f2813 Trivial: Fix docs for functions
This patch fixes some comments in code:
 - Now suffixes can be string in _merge_candidates()
 - Remove old doc for `allow_forbidden` parameter in
   RequestGroup.dict_from_request
 - Delete unnecessary space in ResourceClassCache

Change-Id: I6ffc19eea84b45dd452bc61d2a2007b6572719ad
2019-07-09 07:44:39 +00:00
Tetsuro Nakamura
8395e3f099 Support same_subtree queryparam
A new same_subtree query parameter will be accepted. The value is
a comma-separated list of request group suffix strings $S. Each must
exactly match a suffix on a granular group somewhere else in the
request. Importantly, the identified request groups need not have
a resources$S.

If this is provided, at least one of the resource providers satisfying
the specified request group must be an ancestor of the rest.

The same_subtree query parameter can be repeated and each repeat group
is treated independently.

Co-Authored-By: Chris Dent <cdent@anticdent.org>
Change-Id: I7fdeac24606359d37f1a7405d22c5797840e1a9e
Story: 2005575
Task: 30784
2019-07-09 07:21:53 +00:00
Zuul
7f72d1e30e Merge "tox: Stop building api-ref docs with the main docs" 2019-07-08 22:32:54 +00:00
Zuul
85e5ff5952 Merge "Add whereto for testing redirect rules" 2019-07-08 22:32:53 +00:00
Zuul
f9cd8d0b0d Merge "Update implemented spec and spec document handling" 2019-07-08 22:22:24 +00:00
Stephen Finucane
8c4ad849fd tox: Stop building api-ref docs with the main docs
We have an 'api-ref' docs target - use that instead.

Change-Id: Ie94add90b507d631a74f4617de7feba56fb0c646
Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
2019-07-08 09:18:31 +01:00
Stephen Finucane
4b4dd5ecf8 Add whereto for testing redirect rules
Use whereto to test that the redirect rules do what we expect.

Change-Id: Id3a8f3b9f372ebe9176f1df917f7a6aac30a8e92
Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
2019-07-08 09:18:18 +01:00