aboutsummaryrefslogtreecommitdiffstats
path: root/node-repository
diff options
context:
space:
mode:
authorMartin Polden <mpolden@mpolden.no>2023-07-17 09:37:33 +0200
committerMartin Polden <mpolden@mpolden.no>2023-07-17 09:37:33 +0200
commitd7a6ce401ee686ed3fb7a194e367405c7c6a9fe9 (patch)
treead8298fe352dde02d5cdeed889dcae80b8e115a4 /node-repository
parenta3ed0c6685b97714af646c65163900983344b67c (diff)
Shorten throttling window in CD
Diffstat (limited to 'node-repository')
-rw-r--r--node-repository/src/main/java/com/yahoo/vespa/hosted/provision/maintenance/HostCapacityMaintainer.java2
-rw-r--r--node-repository/src/main/java/com/yahoo/vespa/hosted/provision/provisioning/Preparer.java2
-rw-r--r--node-repository/src/main/java/com/yahoo/vespa/hosted/provision/provisioning/ProvisioningThrottler.java22
3 files changed, 15 insertions, 11 deletions
diff --git a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/maintenance/HostCapacityMaintainer.java b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/maintenance/HostCapacityMaintainer.java
index 377ba11d170..8a9a29f58c6 100644
--- a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/maintenance/HostCapacityMaintainer.java
+++ b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/maintenance/HostCapacityMaintainer.java
@@ -68,7 +68,7 @@ public class HostCapacityMaintainer extends NodeRepositoryMaintainer {
super(nodeRepository, interval, metric);
this.hostProvisioner = hostProvisioner;
this.preprovisionCapacityFlag = PermanentFlags.PREPROVISION_CAPACITY.bindTo(flagSource);
- this.throttler = new ProvisioningThrottler(nodeRepository.clock(), metric);
+ this.throttler = new ProvisioningThrottler(nodeRepository, metric);
}
@Override
diff --git a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/provisioning/Preparer.java b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/provisioning/Preparer.java
index 6db8701041e..79b1bccbbde 100644
--- a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/provisioning/Preparer.java
+++ b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/provisioning/Preparer.java
@@ -43,7 +43,7 @@ public class Preparer {
this.nodeRepository = nodeRepository;
this.hostProvisioner = hostProvisioner;
this.loadBalancerProvisioner = loadBalancerProvisioner;
- this.throttler = new ProvisioningThrottler(nodeRepository.clock(), metric);
+ this.throttler = new ProvisioningThrottler(nodeRepository, metric);
}
/**
diff --git a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/provisioning/ProvisioningThrottler.java b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/provisioning/ProvisioningThrottler.java
index a1d4668acf3..3a11ac76085 100644
--- a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/provisioning/ProvisioningThrottler.java
+++ b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/provisioning/ProvisioningThrottler.java
@@ -4,10 +4,10 @@ package com.yahoo.vespa.hosted.provision.provisioning;
import com.yahoo.jdisc.Metric;
import com.yahoo.vespa.hosted.provision.Node;
import com.yahoo.vespa.hosted.provision.NodeList;
+import com.yahoo.vespa.hosted.provision.NodeRepository;
import com.yahoo.vespa.hosted.provision.node.Agent;
import com.yahoo.vespa.hosted.provision.node.History;
-import java.time.Clock;
import java.time.Duration;
import java.time.Instant;
import java.util.Objects;
@@ -28,36 +28,40 @@ public class ProvisioningThrottler {
private static final int MIN_SIZE = 100;
private static final int MAX_GROWTH = 200;
private static final double MAX_GROWTH_RATE = 0.4;
- private static final Duration WINDOW = Duration.ofHours(8);
- private final Clock clock;
+ private final NodeRepository nodeRepository;
private final Metric metric;
- public ProvisioningThrottler(Clock clock, Metric metric) {
- this.clock = Objects.requireNonNull(clock);
+ public ProvisioningThrottler(NodeRepository nodeRepository, Metric metric) {
+ this.nodeRepository = Objects.requireNonNull(nodeRepository);
this.metric = Objects.requireNonNull(metric);
}
+ private Duration window() {
+ return nodeRepository.zone().system().isCd() ? Duration.ofHours(2) : Duration.ofHours(8);
+ }
+
/** Returns whether provisioning should be throttled at given instant */
public boolean throttle(NodeList allNodes, Agent agent) {
- Instant startOfWindow = clock.instant().minus(WINDOW);
+ Duration window = window();
+ Instant startOfWindow = nodeRepository.clock().instant().minus(window);
NodeList hosts = allNodes.hosts();
int existingHosts = hosts.not().state(Node.State.deprovisioned).size();
int provisionedRecently = hosts.matching(host -> host.history().hasEventAfter(History.Event.Type.provisioned, startOfWindow))
.size();
- boolean throttle = throttle(provisionedRecently, existingHosts, agent);
+ boolean throttle = throttle(provisionedRecently, existingHosts, window, agent);
metric.set(throttlingActiveMetric, throttle ? 1 : 0, null);
return throttle;
}
- static boolean throttle(int recent, int total, Agent agent) {
+ static boolean throttle(int recent, int total, Duration window, Agent agent) {
if (total < MIN_SIZE && recent < MIN_SIZE) return false; // Allow burst in small zones
int maxGrowth = Math.min(MAX_GROWTH, (int) (total * MAX_GROWTH_RATE));
boolean throttle = recent > maxGrowth;
if (throttle) {
LOG.warning(String.format("Throttling provisioning of new hosts by %s: %d hosts have been provisioned " +
"in the past %s, which exceeds growth limit of %d", agent,
- recent, WINDOW, maxGrowth));
+ recent, window, maxGrowth));
}
return throttle;
}