diff options
author | Jon Marius Venstad <jonmv@users.noreply.github.com> | 2022-05-12 13:56:34 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-05-12 13:56:34 +0200 |
commit | 0b23522f1bb461307d6b6fb25c3eaaff2f361698 (patch) | |
tree | 5d08d39261de126fdb828ba313dfecb7f6e6582f /node-repository/src/main | |
parent | 1c87a38df4b51626606f5eb8ee78d146016ecc12 (diff) | |
parent | 62a00713f3207dacbbe6a6054cdef5b450908347 (diff) |
Merge pull request #22501 from vespa-engine/jonmv/decide-default-flavour-based-on-version
Decide default flavours based on requested Vespa version
Diffstat (limited to 'node-repository/src/main')
-rw-r--r-- | node-repository/src/main/java/com/yahoo/vespa/hosted/provision/provisioning/CapacityPolicies.java | 30 |
1 files changed, 22 insertions, 8 deletions
diff --git a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/provisioning/CapacityPolicies.java b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/provisioning/CapacityPolicies.java index 6748b6a2029..aa9fac660f6 100644 --- a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/provisioning/CapacityPolicies.java +++ b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/provisioning/CapacityPolicies.java @@ -1,6 +1,7 @@ // Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.vespa.hosted.provision.provisioning; +import com.yahoo.component.Version; import com.yahoo.config.provision.ApplicationId; import com.yahoo.config.provision.Capacity; import com.yahoo.config.provision.ClusterResources; @@ -12,11 +13,14 @@ import com.yahoo.vespa.flags.FlagSource; import com.yahoo.vespa.flags.PermanentFlags; import com.yahoo.vespa.hosted.provision.NodeRepository; +import java.util.Map; +import java.util.TreeMap; import java.util.function.Function; import static com.yahoo.config.provision.NodeResources.Architecture; import static com.yahoo.vespa.flags.FetchVector.Dimension.APPLICATION_ID; import static com.yahoo.vespa.flags.PermanentFlags.ADMIN_CLUSTER_NODE_ARCHITECTURE; +import static java.util.Objects.requireNonNull; /** * Defines the policies for assigning cluster capacity in various environments @@ -83,17 +87,27 @@ public class CapacityPolicies { .with(APPLICATION_ID, applicationId.serializedForm()) .value()); - if (clusterSpec.id().value().equals("cluster-controllers")) - return new NodeResources(0.25, 1.14, 10, 0.3).with(architecture); + if (clusterSpec.id().value().equals("cluster-controllers")) { + return versioned(clusterSpec, Map.of(new Version("1"), new NodeResources(0.25, 1.14, 10, 0.3))) + .with(architecture); + } - return zone.getCloud().dynamicProvisioning() && ! sharedHosts.apply(clusterSpec.type()) ? - new NodeResources(0.5, 4, 50, 0.3).with(architecture) : - new NodeResources(0.5, 2, 50, 0.3).with(architecture); + return (zone.getCloud().dynamicProvisioning() && ! sharedHosts.apply(clusterSpec.type()) + ? versioned(clusterSpec, Map.of(new Version("1"), new NodeResources(0.5, 4, 50, 0.3))) + : versioned(clusterSpec, Map.of(new Version("1"), new NodeResources(0.5, 2, 50, 0.3)))) + .with(architecture); } - return zone.getCloud().dynamicProvisioning() ? - new NodeResources(2.0, 8, 50, 0.3) : - new NodeResources(1.5, 8, 50, 0.3); + return zone.getCloud().dynamicProvisioning() + ? versioned(clusterSpec, Map.of(new Version("1"), new NodeResources(2.0, 8, 50, 0.3))) + : versioned(clusterSpec, Map.of(new Version("1"), new NodeResources(1.5, 8, 50, 0.3))); + } + + /** Returns the resources for the newest version not newer than that requested in the cluster spec. */ + static NodeResources versioned(ClusterSpec spec, Map<Version, NodeResources> resources) { + return requireNonNull(new TreeMap<>(resources).floorEntry(spec.vespaVersion()), + "no default resources applicable for " + spec + " among: " + resources) + .getValue(); } /** |