summaryrefslogtreecommitdiffstats
path: root/node-repository
diff options
context:
space:
mode:
authorJon Bratseth <bratseth@gmail.com>2021-03-09 16:01:41 +0100
committerJon Bratseth <bratseth@gmail.com>2021-03-09 16:03:29 +0100
commitc22eee67523c9522c15bb087a738eeb18c457d5c (patch)
tree81d642bb34b917b0215fe90f4867a124ae4cc3d9 /node-repository
parentc9b8a01baf870148ed0be5889867152c83e81aa7 (diff)
Add some more /0 checking
Diffstat (limited to 'node-repository')
-rw-r--r--node-repository/src/main/java/com/yahoo/vespa/hosted/provision/autoscale/ClusterTimeseries.java1
-rw-r--r--node-repository/src/main/java/com/yahoo/vespa/hosted/provision/autoscale/ResourceTarget.java4
2 files changed, 4 insertions, 1 deletions
diff --git a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/autoscale/ClusterTimeseries.java b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/autoscale/ClusterTimeseries.java
index bc0fe528464..5b6ed43b713 100644
--- a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/autoscale/ClusterTimeseries.java
+++ b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/autoscale/ClusterTimeseries.java
@@ -85,6 +85,7 @@ public class ClusterTimeseries {
public double currentQueryFractionOfMax() {
if (snapshots.isEmpty()) return 0.5;
var max = snapshots.stream().mapToDouble(ClusterMetricSnapshot::queryRate).max().getAsDouble();
+ if (max == 0) return 1.0;
return snapshots.get(snapshots.size() - 1).queryRate() / max;
}
diff --git a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/autoscale/ResourceTarget.java b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/autoscale/ResourceTarget.java
index c7151e3ae7b..d2bfecfcdae 100644
--- a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/autoscale/ResourceTarget.java
+++ b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/autoscale/ResourceTarget.java
@@ -79,7 +79,9 @@ public class ResourceTarget {
Duration scalingDuration = clusterNodesTimeseries.cluster().scalingDuration(clusterNodesTimeseries.clusterNodes().clusterSpec());
double growthRateHeadroom = 1 + maxGrowthRate * scalingDuration.toMinutes();
// Cap headroom at 10% above the historical observed peak
- growthRateHeadroom = Math.min(growthRateHeadroom, 1 / clusterTimeseries.currentQueryFractionOfMax() + 0.1);
+ double fractionOfMax = clusterTimeseries.currentQueryFractionOfMax();
+ if (fractionOfMax != 0)
+ growthRateHeadroom = Math.min(growthRateHeadroom, 1 / fractionOfMax + 0.1);
// How much headroom is needed to handle sudden arrival of additional traffic due to another zone going down?
double trafficShiftHeadroom;