From 7f1dee530238f2f19e9423e4fc192564325a0b82 Mon Sep 17 00:00:00 2001 From: Chris Dent Date: Tue, 23 Jan 2018 11:57:48 +0000 Subject: [PATCH] Fix nits in allocation candidate limit handling In the review for I5f3d4f49c34fd3cd6b9d2e12b3c3c4cdcb409bec some non-blocking issues were identified. They are fixed here: * inconsistent indentation in configuration setting * creation of a uuid tracking set in the wrong block Change-Id: I848d60f9a5d66cae584279f99a50b9e871540baf --- nova/conf/placement.py | 7 ++++--- nova/objects/resource_provider.py | 12 +++++------- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/nova/conf/placement.py b/nova/conf/placement.py index 74cefbc11253..e5f627cbdb18 100644 --- a/nova/conf/placement.py +++ b/nova/conf/placement.py @@ -50,9 +50,10 @@ Possible values: Endpoint interface for this node. This is used when picking the URL in the service catalog. """), - cfg.BoolOpt('randomize_allocation_candidates', - default=False, - help=""" + cfg.BoolOpt( + 'randomize_allocation_candidates', + default=False, + help=""" If True, when limiting allocation candidate results, the results will be a random sampling of the full result set. If False, allocation candidates are returned in a deterministic but undefined order. That is, all things diff --git a/nova/objects/resource_provider.py b/nova/objects/resource_provider.py index 5d26536eaf60..bc3058aff9ad 100644 --- a/nova/objects/resource_provider.py +++ b/nova/objects/resource_provider.py @@ -3567,24 +3567,22 @@ class AllocationCandidates(base.NovaObject): # needing to mess with the complex sql above or add additional # columns to the DB. - # Track the resource provider uuids that we have chosen so that - # we can pull out their summaries below. - alloc_req_rp_uuids = set() if limit and limit <= len(alloc_request_objs): if CONF.placement.randomize_allocation_candidates: alloc_request_objs = random.sample(alloc_request_objs, limit) else: alloc_request_objs = alloc_request_objs[:limit] - # Extract resource provider uuids from the resource requests. - for aro in alloc_request_objs: - for arr in aro.resource_requests: - alloc_req_rp_uuids.add(arr.resource_provider.uuid) elif CONF.placement.randomize_allocation_candidates: random.shuffle(alloc_request_objs) # Limit summaries to only those mentioned in the allocation requests. if limit and limit <= len(alloc_request_objs): kept_summary_objs = [] + alloc_req_rp_uuids = set() + # Extract resource provider uuids from the resource requests. + for aro in alloc_request_objs: + for arr in aro.resource_requests: + alloc_req_rp_uuids.add(arr.resource_provider.uuid) for summary in summary_objs: rp_uuid = summary.resource_provider.uuid # Skip a summary if we are limiting and haven't selected an