diff options
author | Harald Musum <musum@yahooinc.com> | 2024-05-30 13:20:36 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-05-30 13:20:36 +0200 |
commit | 75954a13dcb9b18708316564f6fd3e96a5918950 (patch) | |
tree | b8f278f9e4bdcd5e00ee658e3076afbff45ac7a4 | |
parent | 2933fb9a42b2bce2c8ed47c6be0a6ecce4006c0f (diff) | |
parent | 7f623d5f31bb00783a8afa74486bb66d739b080e (diff) |
Merge pull request #31361 from vespa-engine/mpolden/require-nodes
Handle cluster removal during autoscaling
2 files changed, 5 insertions, 14 deletions
diff --git a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/autoscale/AllocatableResources.java b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/autoscale/AllocatableResources.java index 79e709e7bae..27216695584 100644 --- a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/autoscale/AllocatableResources.java +++ b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/autoscale/AllocatableResources.java @@ -48,8 +48,11 @@ public class AllocatableResources { } public AllocatableResources(NodeList nodes, NodeRepository nodeRepository) { + if (nodes.isEmpty()) { + throw new IllegalArgumentException("Expected a non-empty node list"); + } this.nodes = nodes.size(); - this.groups = (int)nodes.stream().map(node -> node.allocation().get().membership().cluster().group()).distinct().count(); + this.groups = (int) nodes.stream().map(node -> node.allocation().get().membership().cluster().group()).distinct().count(); this.realResources = averageRealResourcesOf(nodes.asList(), nodeRepository); // Average since we average metrics over nodes this.advertisedResources = nodes.requestedResources(); this.clusterSpec = nodes.clusterSpec(); @@ -82,19 +85,6 @@ public class AllocatableResources { this.fulfilment = fulfilment; } - /** Returns this with the redundant node or group removed from counts. */ - public AllocatableResources withoutRedundancy() { - int groupSize = nodes / groups; - int nodesAdjustedForRedundancy = nodes > 1 ? (groups == 1 ? nodes - 1 : nodes - groupSize) : nodes; - int groupsAdjustedForRedundancy = nodes > 1 ? (groups == 1 ? 1 : groups - 1) : groups; - return new AllocatableResources(nodesAdjustedForRedundancy, - groupsAdjustedForRedundancy, - realResources, - advertisedResources, - clusterSpec, - fulfilment); - } - /** * Returns the resources which will actually be available per node in this cluster with this allocation. * These should be used for reasoning about allocation to meet measured demand. 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 5c9c5fe30d7..471b9d0122f 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 @@ -91,6 +91,7 @@ public class AutoscalingMaintainer extends NodeRepositoryMaintainer { Cluster unchangedCluster = cluster; NodeList clusterNodes = nodeRepository().nodes().list(Node.State.active).owner(applicationId).cluster(clusterId); + if (clusterNodes.isEmpty()) return true; // Cluster was removed since we started cluster = updateCompletion(cluster, clusterNodes); var current = new AllocatableResources(clusterNodes.not().retired(), nodeRepository()).advertisedResources(); |