diff options
author | Jon Bratseth <bratseth@gmail.com> | 2022-12-29 17:40:17 +0100 |
---|---|---|
committer | Jon Bratseth <bratseth@gmail.com> | 2022-12-29 17:40:17 +0100 |
commit | 2678acf4d40a5673343d6fdd1b1fe66a4fc73df7 (patch) | |
tree | d11dbc8d4eb8519458f766ce203025d54e21d441 /node-repository/src/main/java/com/yahoo/vespa/hosted/provision/maintenance | |
parent | 2279ce96234d01cf039a319ce390a96e431437cc (diff) |
Use Autoscaling in place of Advice
Diffstat (limited to 'node-repository/src/main/java/com/yahoo/vespa/hosted/provision/maintenance')
2 files changed, 12 insertions, 13 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 7eedad98697..caeed18961e 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 @@ -70,9 +70,9 @@ public class AutoscalingMaintainer extends NodeRepositoryMaintainer { if (cluster.isEmpty()) return; Cluster updatedCluster = updateCompletion(cluster.get(), clusterNodes); - var advice = autoscaler.autoscale(application.get(), updatedCluster, clusterNodes); + var autoscaling = autoscaler.autoscale(application.get(), updatedCluster, clusterNodes); - if ( ! anyChanges(advice, cluster.get(), updatedCluster, clusterNodes)) return; + if ( ! anyChanges(autoscaling, cluster.get(), updatedCluster, clusterNodes)) return; try (var lock = nodeRepository().applications().lock(applicationId)) { application = nodeRepository().applications().get(applicationId); @@ -82,29 +82,28 @@ public class AutoscalingMaintainer extends NodeRepositoryMaintainer { clusterNodes = nodeRepository().nodes().list(Node.State.active).owner(applicationId).cluster(clusterId); // 1. Update cluster info - updatedCluster = updateCompletion(cluster.get(), clusterNodes) - .withTarget(new Autoscaling(advice.target(), advice.reason(), nodeRepository().clock().instant())); + updatedCluster = updateCompletion(cluster.get(), clusterNodes).withTarget(autoscaling); applications().put(application.get().with(updatedCluster), lock); var current = new AllocatableClusterResources(clusterNodes, nodeRepository()).advertisedResources(); - if (advice.target().isPresent() && !current.equals(advice.target().get())) { + if (autoscaling.resources().isPresent() && !current.equals(autoscaling.resources().get())) { // 2. Also autoscale try (MaintenanceDeployment deployment = new MaintenanceDeployment(applicationId, deployer, metric, nodeRepository())) { if (deployment.isValid()) { deployment.activate(); - logAutoscaling(current, advice.target().get(), applicationId, clusterNodes); + logAutoscaling(current, autoscaling.resources().get(), applicationId, clusterNodes); } } } } } - private boolean anyChanges(Autoscaler.Advice advice, Cluster cluster, Cluster updatedCluster, NodeList clusterNodes) { + private boolean anyChanges(Autoscaling autoscaling, Cluster cluster, Cluster updatedCluster, NodeList clusterNodes) { if (updatedCluster != cluster) return true; - if (!cluster.target().resources().equals(advice.target())) return true; - if ( ! advice.reason().equals(cluster.target().status())) return true; - if (advice.target().isPresent() && - !advice.target().get().equals(new AllocatableClusterResources(clusterNodes, nodeRepository()).advertisedResources())) 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; } 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 248329966cc..e6fadc5f5bd 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 @@ -64,10 +64,10 @@ public class ScalingSuggestionsMaintainer extends NodeRepositoryMaintainer { Optional<Cluster> cluster = application.cluster(clusterId); if (cluster.isEmpty()) return true; var suggestion = autoscaler.suggest(application, cluster.get(), clusterNodes); - if (suggestion.reason().status() == AutoscalingStatus.Status.waiting) return true; + if (suggestion.status().status() == AutoscalingStatus.Status.waiting) return true; // empty suggested resources == keep the current allocation - var suggestedResources = suggestion.target().orElse(clusterNodes.not().retired().toResources()); + var suggestedResources = suggestion.resources().orElse(clusterNodes.not().retired().toResources()); if ( ! shouldUpdateSuggestion(cluster.get().suggested(), suggestedResources)) return true; // Wait only a short time for the lock to avoid interfering with change deployments |