aboutsummaryrefslogtreecommitdiffstats
path: root/node-repository
diff options
context:
space:
mode:
authorJon Bratseth <bratseth@gmail.com>2021-01-18 11:09:38 +0100
committerJon Bratseth <bratseth@gmail.com>2021-01-18 11:09:38 +0100
commit0511fde99cc34f43bc0a6402f3348aab5fc28589 (patch)
tree8fb760badde601634545ffd71b0e25da9ae5ef32 /node-repository
parentbfcaecfd435060caf59dd39ea391a1720876e3a5 (diff)
Set suggestion to highest oberved over a week
Since suggestions are consumed by humans they should change on the time scale of human decision making.
Diffstat (limited to 'node-repository')
-rw-r--r--node-repository/src/main/java/com/yahoo/vespa/hosted/provision/maintenance/ScalingSuggestionsMaintainer.java11
-rw-r--r--node-repository/src/test/java/com/yahoo/vespa/hosted/provision/maintenance/ScalingSuggestionsMaintainerTest.java15
2 files changed, 25 insertions, 1 deletions
diff --git a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/maintenance/ScalingSuggestionsMaintainer.java b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/maintenance/ScalingSuggestionsMaintainer.java
index d75cfbecee7..be8966068c9 100644
--- a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/maintenance/ScalingSuggestionsMaintainer.java
+++ b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/maintenance/ScalingSuggestionsMaintainer.java
@@ -85,7 +85,16 @@ public class ScalingSuggestionsMaintainer extends NodeRepositoryMaintainer {
Optional<Cluster> cluster = application.cluster(clusterId);
if (cluster.isEmpty()) return;
var at = nodeRepository().clock().instant();
- applications().put(application.with(cluster.get().withSuggested(suggestion.map(s -> new Cluster.Suggestion(s, at)))), lock);
+ var currentSuggestion = cluster.get().suggestedResources();
+ if (currentSuggestion.isEmpty()
+ || currentSuggestion.get().at().isBefore(at.minus(Duration.ofDays(7)))
+ || suggestion.isPresent() && isHigher(suggestion.get(), currentSuggestion.get().resources()))
+ applications().put(application.with(cluster.get().withSuggested(suggestion.map(s -> new Cluster.Suggestion(s, at)))), lock);
+ }
+
+ private boolean isHigher(ClusterResources r1, ClusterResources r2) {
+ // Use cost as a measure of "highness" over multiple dimensions
+ return r1.totalResources().cost() > r2.totalResources().cost();
}
private Map<ClusterSpec.Id, List<Node>> nodesByCluster(List<Node> applicationNodes) {
diff --git a/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/maintenance/ScalingSuggestionsMaintainerTest.java b/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/maintenance/ScalingSuggestionsMaintainerTest.java
index 069759c43f2..5ec29cb9043 100644
--- a/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/maintenance/ScalingSuggestionsMaintainerTest.java
+++ b/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/maintenance/ScalingSuggestionsMaintainerTest.java
@@ -70,6 +70,21 @@ public class ScalingSuggestionsMaintainerTest {
tester.nodeRepository().applications().get(app1).get().cluster(cluster1.id()).get().suggestedResources().get().resources().toString());
assertEquals("8 nodes with [vcpu: 14.7, memory: 4.0 Gb, disk 11.8 Gb, bandwidth: 0.1 Gbps, storage type: remote]",
tester.nodeRepository().applications().get(app2).get().cluster(cluster2.id()).get().suggestedResources().get().resources().toString());
+
+ // Utilization goes way down
+ tester.clock().advance(Duration.ofHours(13));
+ addMeasurements(0.10f, 0.10f, 0.10f, 0, 500, app1, tester.nodeRepository(), metricsDb);
+ maintainer.maintain();
+ assertEquals("Suggestion stays at the peak value observed",
+ "14 nodes with [vcpu: 6.9, memory: 5.1 Gb, disk 15.0 Gb, bandwidth: 0.1 Gbps, storage type: remote]",
+ tester.nodeRepository().applications().get(app1).get().cluster(cluster1.id()).get().suggestedResources().get().resources().toString());
+ // Utilization is still way down and a week has passed
+ tester.clock().advance(Duration.ofDays(7));
+ addMeasurements(0.10f, 0.10f, 0.10f, 0, 500, app1, tester.nodeRepository(), metricsDb);
+ maintainer.maintain();
+ assertEquals("Peak suggestion has been outdated",
+ "6 nodes with [vcpu: 2.0, memory: 4.0 Gb, disk 10.0 Gb, bandwidth: 0.1 Gbps, storage type: remote]",
+ tester.nodeRepository().applications().get(app1).get().cluster(cluster1.id()).get().suggestedResources().get().resources().toString());
}
public void addMeasurements(float cpu, float memory, float disk, int generation, int count, ApplicationId applicationId,