diff options
Diffstat (limited to 'node-repository/src/main/java/com/yahoo/vespa/hosted/provision/autoscale/AllocationOptimizer.java')
-rw-r--r-- | node-repository/src/main/java/com/yahoo/vespa/hosted/provision/autoscale/AllocationOptimizer.java | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/autoscale/AllocationOptimizer.java b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/autoscale/AllocationOptimizer.java index 9a8b01f33af..1c99ea7dc08 100644 --- a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/autoscale/AllocationOptimizer.java +++ b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/autoscale/AllocationOptimizer.java @@ -6,6 +6,7 @@ import com.yahoo.config.provision.NodeResources; import com.yahoo.vespa.hosted.provision.NodeList; import com.yahoo.vespa.hosted.provision.NodeRepository; +import java.util.List; import java.util.Optional; /** @@ -43,7 +44,11 @@ public class AllocationOptimizer { else limits = atLeast(minimumNodes, limits).fullySpecified(current.clusterSpec(), nodeRepository, clusterModel.application().id()); Optional<AllocatableClusterResources> bestAllocation = Optional.empty(); - NodeList hosts = nodeRepository.nodes().list().hosts(); + var availableRealHostResources = nodeRepository.zone().cloud().dynamicProvisioning() + ? nodeRepository.flavors().getFlavors().stream().map(flavor -> flavor.resources()).toList() + : nodeRepository.nodes().list().hosts().stream().map(host -> host.flavor().resources()) + .map(hostResources -> maxResourcesOf(hostResources, clusterModel)) + .toList(); for (int groups = limits.min().groups(); groups <= limits.max().groups(); groups++) { for (int nodes = limits.min().nodes(); nodes <= limits.max().nodes(); nodes++) { if (nodes % groups != 0) continue; @@ -53,7 +58,7 @@ public class AllocationOptimizer { nodeResourcesWith(nodes, groups, limits, targetLoad, current, clusterModel)); var allocatableResources = AllocatableClusterResources.from(resources, current.clusterSpec(), limits, - hosts, nodeRepository); + availableRealHostResources, nodeRepository); if (allocatableResources.isEmpty()) continue; if (bestAllocation.isEmpty() || allocatableResources.get().preferableTo(bestAllocation.get())) bestAllocation = allocatableResources; @@ -62,6 +67,13 @@ public class AllocationOptimizer { return bestAllocation; } + /** Returns the max resources of a host one node may allocate. */ + private NodeResources maxResourcesOf(NodeResources hostResources, ClusterModel clusterModel) { + if (nodeRepository.exclusiveAllocation(clusterModel.clusterSpec())) return hostResources; + // static, shared hosts: Allocate at most half of the host cpu to simplify management + return hostResources.withVcpu(hostResources.vcpu() / 2); + } + /** * For the observed load this instance is initialized with, returns the resources needed per node to be at * the target relative load, given a target node and group count. |