From c8fb01b59d4800c980c92b47cccd229dae9f6da4 Mon Sep 17 00:00:00 2001 From: Balazs Gibizer Date: Wed, 27 Mar 2019 18:25:31 +0100 Subject: [PATCH] Change the TODO to NOTE about instance multi-create The _fill_provider_mapping() calls the placement to get traits of the RPs in the allocation for each instance during build. In a multi create request multiple instance might hit the same compute host so caching the traits of the RPs on those compute host reduces the placement load. However multi-create can be used with port's that has resource request (those the one that triggers _fill_provider_mapping) because for multi create to work the user needs to pass networks to the server create API insted of pre-created Neutron ports. However ports with resource request only supported if pre-created ports are passed to the server create API. Therefore this patch corrects the TODO about multi-create in _fill_provider_mapping. Change-Id: I8e8248981b533cb4c37e89009f5839e41d9c6649 --- nova/conductor/manager.py | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/nova/conductor/manager.py b/nova/conductor/manager.py index fd74425d5fd8..19c3c67e92a9 100644 --- a/nova/conductor/manager.py +++ b/nova/conductor/manager.py @@ -1297,14 +1297,15 @@ class ComputeTaskManager(base.Base): ar = jsonutils.loads(host_selection.allocation_request) allocs = ar['allocations'] - # TODO(mriedem): Short-term we can optimize this by passing a cache by - # reference of the RP->traits mapping because if we are processing - # a multi-create request we could have the same RPs being used for - # multiple instances and avoid duplicate calls. Long-term we could - # stash the RP->traits mapping on the Selection object since we can - # pull the traits for each provider from the GET /allocation_candidates - # response in the scheduler (or leverage the change from the spec - # mentioned in the docstring above). + # NOTE(gibi): Getting traits from placement for each instance in a + # instance multi-create scenario is unnecessarily expensive. But + # instance multi-create cannot be used with pre-created neutron ports + # and this code can only be triggered with such pre-created ports so + # instance multi-create is not an issue. If this ever become an issue + # in the future then we could stash the RP->traits mapping on the + # Selection object since we can pull the traits for each provider from + # the GET /allocation_candidates response in the scheduler (or leverage + # the change from the spec mentioned in the docstring above). provider_traits = { rp_uuid: self.report_client.get_provider_traits( context, rp_uuid).traits