aboutsummaryrefslogtreecommitdiffstats
path: root/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/maintenance
diff options
context:
space:
mode:
authorJon Bratseth <bratseth@gmail.com>2023-01-11 13:03:20 +0100
committerJon Bratseth <bratseth@gmail.com>2023-01-11 13:03:20 +0100
commit4fdb2ea60b8ef9852e8e73ba8dd54fd1bf64c846 (patch)
tree8081ecb7e9d6aed73ec7d95dc2429a3c5e6f5c2c /node-repository/src/main/java/com/yahoo/vespa/hosted/provision/maintenance
parentafb9f81ffd4befa141dfb22d64190a5725d001e7 (diff)
Always write autoscaling updates
Since we're storing the load used to make decisions, there will almost always be changes to write, so remove optimization to avoid it.
Diffstat (limited to 'node-repository/src/main/java/com/yahoo/vespa/hosted/provision/maintenance')
-rw-r--r--node-repository/src/main/java/com/yahoo/vespa/hosted/provision/maintenance/AutoscalingMaintainer.java32
1 files changed, 8 insertions, 24 deletions
diff --git a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/maintenance/AutoscalingMaintainer.java b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/maintenance/AutoscalingMaintainer.java
index 4aa54b7f6fa..f792c511adb 100644
--- a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/maintenance/AutoscalingMaintainer.java
+++ b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/maintenance/AutoscalingMaintainer.java
@@ -56,30 +56,23 @@ public class AutoscalingMaintainer extends NodeRepositoryMaintainer {
private void autoscale(ApplicationId application, NodeList applicationNodes) {
try {
- nodesByCluster(applicationNodes).forEach((clusterId, clusterNodes) -> autoscale(application, clusterId, clusterNodes));
+ nodesByCluster(applicationNodes).forEach((clusterId, clusterNodes) -> autoscale(application, clusterId));
}
catch (IllegalArgumentException e) {
throw new IllegalArgumentException("Illegal arguments for " + application, e);
}
}
- private void autoscale(ApplicationId applicationId, ClusterSpec.Id clusterId, NodeList clusterNodes) {
- Optional<Application> application = nodeRepository().applications().get(applicationId);
- if (application.isEmpty()) return;
- Optional<Cluster> cluster = application.get().cluster(clusterId);
- if (cluster.isEmpty()) return;
-
- Cluster updatedCluster = updateCompletion(cluster.get(), clusterNodes);
- var autoscaling = autoscaler.autoscale(application.get(), updatedCluster, clusterNodes);
-
- if ( ! anyChanges(autoscaling, cluster.get(), updatedCluster, clusterNodes)) return;
-
+ private void autoscale(ApplicationId applicationId, ClusterSpec.Id clusterId) {
try (var lock = nodeRepository().applications().lock(applicationId)) {
- application = nodeRepository().applications().get(applicationId);
+ Optional<Application> application = nodeRepository().applications().get(applicationId);
if (application.isEmpty()) return;
- cluster = application.get().cluster(clusterId);
+ Optional<Cluster> cluster = application.get().cluster(clusterId);
if (cluster.isEmpty()) return;
- clusterNodes = nodeRepository().nodes().list(Node.State.active).owner(applicationId).cluster(clusterId);
+
+ NodeList clusterNodes = nodeRepository().nodes().list(Node.State.active).owner(applicationId).cluster(clusterId);
+ Cluster updatedCluster = updateCompletion(cluster.get(), clusterNodes);
+ var autoscaling = autoscaler.autoscale(application.get(), updatedCluster, clusterNodes);
// 1. Update cluster info
updatedCluster = updateCompletion(cluster.get(), clusterNodes);
@@ -100,15 +93,6 @@ public class AutoscalingMaintainer extends NodeRepositoryMaintainer {
}
}
- private boolean anyChanges(Autoscaling autoscaling, Cluster cluster, Cluster updatedCluster, NodeList clusterNodes) {
- if (updatedCluster != cluster) return true;
- if ( ! cluster.target().resources().equals(autoscaling.resources())) return true;
- if ( ! cluster.target().status().equals(autoscaling.status())) return true;
- if (autoscaling.resources().isPresent() &&
- !autoscaling.resources().get().equals(new AllocatableClusterResources(clusterNodes, nodeRepository()).advertisedResources())) return true;
- return false;
- }
-
private Applications applications() {
return nodeRepository().applications();
}