summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJon Bratseth <bratseth@gmail.com>2022-08-03 16:29:55 +0200
committerJon Bratseth <bratseth@gmail.com>2022-08-03 16:29:55 +0200
commit972b5932c876988a07ad4ffe7f5d34234337f851 (patch)
treeb6e548b84737b8c1dab5de11eb72e17722bd644e
parentbeeee393fd2479ae092936ea313e92cebe3899e3 (diff)
Pull redundancy adjustment into callee
-rw-r--r--node-repository/src/main/java/com/yahoo/vespa/hosted/provision/autoscale/AllocationOptimizer.java14
-rw-r--r--node-repository/src/main/java/com/yahoo/vespa/hosted/provision/autoscale/ClusterModel.java20
2 files changed, 15 insertions, 19 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 8c01696d275..29f53f0336d 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
@@ -47,17 +47,10 @@ public class AllocationOptimizer {
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;
- int groupSize = nodes / groups;
-
- // Adjust for redundancy: Node in group if groups = 1, an extra group if multiple groups
- // TODO: Make the best choice between those two based on size and redundancy setting instead
- int nodesAdjustedForRedundancy = clusterModel.nodesAdjustedForRedundancy(nodes, groups);
- int groupsAdjustedForRedundancy = clusterModel.groupsAdjustedForRedundancy(nodes, groups);
ClusterResources next = new ClusterResources(nodes,
groups,
- nodeResourcesWith(nodesAdjustedForRedundancy,
- groupsAdjustedForRedundancy,
+ nodeResourcesWith(nodes, groups,
limits, target, current, clusterModel));
var allocatableResources = AllocatableClusterResources.from(next, current.clusterSpec(), limits,
hosts, nodeRepository);
@@ -79,11 +72,8 @@ public class AllocationOptimizer {
ResourceTarget target,
AllocatableClusterResources current,
ClusterModel clusterModel) {
- int currentNodes = clusterModel.nodesAdjustedForRedundancy(clusterModel.nodeCount(), clusterModel.groupCount());
- int currentGroups = clusterModel.groupsAdjustedForRedundancy(clusterModel.nodeCount(), clusterModel.groupCount());
-
var scaled = clusterModel.loadWith(nodes, groups)
- .scaled(Load.one().divide(clusterModel.loadWith(currentNodes, currentGroups)).scaled(target.resources()));
+ .scaled(Load.one().divide(clusterModel.redundancyAdjustment()).scaled(target.resources()));
// Combine the scaled resource values computed here
// with the currently configured non-scaled values, given in the limits, if any
var nonScaled = limits.isEmpty() || limits.min().nodeResources().isUnspecified()
diff --git a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/autoscale/ClusterModel.java b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/autoscale/ClusterModel.java
index abcd626e64a..ae18e7ffb91 100644
--- a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/autoscale/ClusterModel.java
+++ b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/autoscale/ClusterModel.java
@@ -152,8 +152,18 @@ public class ClusterModel {
return (int)Math.ceil((double)nodeCount() / groupCount());
}
- /** Returns the relative load adjustment given these nodes+groups relative to node nodes+groups in this. */
- public Load loadWith(int nodes, int groups) {
+ /** Returns the relative load adjustment accounting for redundancy in this. */
+ public Load redundancyAdjustment() {
+ return loadWith(nodeCount(), groupCount());
+ }
+
+ /**
+ * Returns the relative load adjustment accounting for redundancy given these nodes+groups
+ * relative to node nodes+groups in this.
+ */
+ public Load loadWith(int trueNodes, int trueGroups) {
+ int nodes = nodesAdjustedForRedundancy(trueNodes, trueGroups);
+ int groups = groupsAdjustedForRedundancy(trueNodes, trueGroups);
if (clusterSpec().type() == ClusterSpec.Type.content) { // load scales with node share of content
int groupSize = nodes / groups;
@@ -179,11 +189,7 @@ public class ClusterModel {
* if one of the nodes go down.
*/
public Load idealLoad() {
- int nodes = nodeCount();
- int groups = groupCount();
- return new Load(idealCpuLoad(), idealMemoryLoad, idealDiskLoad())
- .divide(loadWith(nodesAdjustedForRedundancy(nodes, groups),
- groupsAdjustedForRedundancy(nodes, groups)));
+ return new Load(idealCpuLoad(), idealMemoryLoad, idealDiskLoad()).divide(redundancyAdjustment());
}
public int nodesAdjustedForRedundancy(int nodes, int groups) {