From c2168f1a9e00f4188a98453d44fb591b10d64685 Mon Sep 17 00:00:00 2001 From: Eric Fried Date: Tue, 28 Aug 2018 17:18:04 -0500 Subject: [PATCH] Other host allocs may appear in gafpt during evac The report client's get_allocations_for_provider_tree tries pretty hard to retrieve only allocations relevant to the compute on which it's running. But it was pointed out during review [1][2] that it's possible to get another host's allocations if the instance is in the middle of an evacuate. So call this out in a couple of places. [1] https://review.openstack.org/#/c/584648/20/nova/scheduler/client/report.py@2002 [2] https://review.openstack.org/#/c/584648/21/nova/scheduler/client/report.py@2063 Change-Id: I94ecdcaf8692f937082ad740218bea8d08c1a87d --- nova/scheduler/client/report.py | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/nova/scheduler/client/report.py b/nova/scheduler/client/report.py index 1d66852c3da9..df41499221ef 100644 --- a/nova/scheduler/client/report.py +++ b/nova/scheduler/client/report.py @@ -2121,6 +2121,14 @@ class SchedulerReportClient(object): This method is (and should remain) used exclusively in the reshaper flow by the resource tracker. + Note that, in addition to allocations on providers in this compute + node's provider tree, this method will return allocations on sharing + providers if those allocations are associated with a consumer on this + compute node. This is intentional and desirable. But it may also return + allocations belonging to other hosts, e.g. if this is happening in the + middle of an evacuate. ComputeDriver.update_provider_tree is supposed + to ignore such allocations if they appear. + :param context: The security context :param nodename: The name of a node for whose tree we are getting allocations. @@ -2173,8 +2181,12 @@ class SchedulerReportClient(object): # The allocations dict is keyed by consumer UUID consumers.update(alloc_info.allocations) - # Now get all the allocations (which will include allocations on - # sharing providers) for each of these consumers to build the result. + # Now get all the allocations for each of these consumers to build the + # result. This will include allocations on sharing providers, which is + # intentional and desirable. But it may also include allocations + # belonging to other hosts, e.g. if this is happening in the middle of + # an evacuate. ComputeDriver.update_provider_tree is supposed to ignore + # such allocations if they appear. # TODO(efried): This could be more efficient if placement offered an # operation like GET /allocations?consumer_uuid=in: return {consumer: self.get_allocs_for_consumer(context, consumer)