placement/placement
Chris Dent 81937773f5 Stabilize AllocationRequest hash
A set of AllocationRequest objects is extended in _merge_candidates,
controlled by the hash of the AllocationRequest, which is based on
a list of AllocationRequestResource objects.

It turns out that this hash can be different depending on the ordering
of the members of the list, with different behaviors in Python 2 and 3.
Therefore, a stable sort is needed to ensure the stability of the hash.

It's quite likely that a sort could have been done elsewhere, but there
are at least two places where resource_requests are added, with
different attributes available for sorting, so this contained
implementation was done instead.

Tests are added that confirms the expected behavior.

Note that the expected behavior will change when we add suffix
mappings to allocation requests. Whereas now
'test_nested_result_count_isolate' gets winnowed to 2 results because
the following are treated as duplicates

   [('cn1', orc.VCPU, 2),
    ('cn1_numa0_pf0', orc.SRIOV_NET_VF, 1),
    ('cn1_numa1_pf1', orc.SRIOV_NET_VF, 1)],
   [('cn1', orc.VCPU, 2),
    ('cn1_numa0_pf0', orc.SRIOV_NET_VF, 1),
    ('cn1_numa1_pf1', orc.SRIOV_NET_VF, 1)],

they are in fact slightly different: one set has pf0 satisfying group
_NET1 and pf1 _NET2, the other vice versa. With mappings available
we presumably want to expose this difference, resulting in more...
results.

An interesting note: The original bug report was that python 2.7 was
varying across 3 values, sometimes right, but mostly wrong and 3.7
was always right. Turns out that 3.7 was consistently wrong, and 2.7
was mostly right, but not always.

Change-Id: I4fce243659d5c429dc3d48f07888e38bd0aed5d4
Story: 2005822
Task: 33579
2019-06-07 15:01:38 +00:00
..
cmd Change "Missing Root Provider IDs" upgrade check to a failure 2019-05-22 14:45:36 -04:00
conf Add register_opts param to PlacementFixture 2019-03-20 22:34:21 +00:00
db Add blocker alembic migration for null root_provider_ids 2019-05-22 15:17:42 -04:00
handlers Merge "Use trait strings in ProviderSummary objects" 2019-05-29 02:53:43 +00:00
objects Stabilize AllocationRequest hash 2019-06-07 15:01:38 +00:00
policies Remove the import pathing for the old structure 2018-09-04 10:31:24 -05:00
schemas Allow [a-zA-Z0-9_-]{1,64} for request group suffix 2019-05-21 11:07:38 +01:00
tests Stabilize AllocationRequest hash 2019-06-07 15:01:38 +00:00
__init__.py Move the placement code to the base 2018-09-04 10:31:23 -05:00
auth.py Remove the import pathing for the old structure 2018-09-04 10:31:24 -05:00
context.py Add online-data-migration DB commands 2019-01-18 14:13:25 +00:00
db_api.py Make the PlacementFixture usable without intercept 2019-03-04 20:55:22 +00:00
deploy.py Optionally run a wsgi profiler when asked 2019-06-05 19:41:18 +00:00
direct.py Remove pep8 whitespace ignores 2019-03-05 18:18:30 -06:00
errors.py Move the placement code to the base 2018-09-04 10:31:23 -05:00
exception.py Add RequestGroupSearchContext class 2019-05-29 15:22:38 -05:00
fault_wrap.py Remove the import pathing for the old structure 2018-09-04 10:31:24 -05:00
handler.py Remove use of oslo.i18n and translation 2019-03-25 16:59:21 +00:00
lib.py Allow [a-zA-Z0-9_-]{1,64} for request group suffix 2019-05-21 11:07:38 +01:00
microversion.py Allow [a-zA-Z0-9_-]{1,64} for request group suffix 2019-05-21 11:07:38 +01:00
policy.py Make policy init more threadsafe 2019-03-12 11:14:41 +00:00
requestlog.py Remove pep8 whitespace ignores 2019-03-05 18:18:30 -06:00
resource_class_cache.py s/rc_cache.ensure_rc_cache/rc_cache.ensure/ 2019-03-26 17:50:38 -05:00
rest_api_version_history.rst Allow [a-zA-Z0-9_-]{1,64} for request group suffix 2019-05-21 11:07:38 +01:00
util.py Negative member_of query with microversion 1.32 2019-03-29 05:14:27 +00:00
wsgi.py Add register_opts param to PlacementFixture 2019-03-20 22:34:21 +00:00
wsgi_wrapper.py Remove the import pathing for the old structure 2018-09-04 10:31:24 -05:00