diff options
Diffstat (limited to 'node-repository/src/main/java/com/yahoo/vespa/hosted/provision/provisioning')
2 files changed, 17 insertions, 10 deletions
diff --git a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/provisioning/NodeAllocation.java b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/provisioning/NodeAllocation.java index d9d7b4a5d12..2a140945f43 100644 --- a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/provisioning/NodeAllocation.java +++ b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/provisioning/NodeAllocation.java @@ -213,23 +213,23 @@ class NodeAllocation { * @return the final list of nodes */ List<Node> finalNodes(List<Node> surplusNodes) { - long currentRetired = nodes.stream().filter(node -> node.node.allocation().get().membership().retired()).count(); - long surplus = requestedNodes.surplusGiven(nodes.size()) - currentRetired; + int currentRetiredCount = (int) nodes.stream().filter(node -> node.node.allocation().get().membership().retired()).count(); + int deltaRetiredCount = requestedNodes.idealRetiredCount(nodes.size(), currentRetiredCount) - currentRetiredCount; - if (surplus > 0) { // retire until surplus is 0, prefer to retire higher indexes to minimize redistribution + if (deltaRetiredCount > 0) { // retire until deltaRetiredCount is 0, prefer to retire higher indexes to minimize redistribution for (PrioritizableNode node : byDecreasingIndex(nodes)) { if ( ! node.node.allocation().get().membership().retired() && node.node.state().equals(Node.State.active)) { node.node = node.node.retire(Agent.application, clock.instant()); surplusNodes.add(node.node); // offer this node to other groups - if (--surplus == 0) break; + if (--deltaRetiredCount == 0) break; } } } - else if (surplus < 0) { // unretire until surplus is 0 + else if (deltaRetiredCount < 0) { // unretire until deltaRetiredCount is 0 for (PrioritizableNode node : byIncreasingIndex(nodes)) { if ( node.node.allocation().get().membership().retired() && hasCompatibleFlavor(node.node)) { node.node = node.node.unretire(); - if (++surplus == 0) break; + if (++deltaRetiredCount == 0) break; } } } diff --git a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/provisioning/NodeSpec.java b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/provisioning/NodeSpec.java index 23a6e3a8b9a..dc3f4a64421 100644 --- a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/provisioning/NodeSpec.java +++ b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/provisioning/NodeSpec.java @@ -34,8 +34,8 @@ public interface NodeSpec { /** Returns whether the given node count is sufficient to fulfill this spec */ boolean fulfilledBy(int count); - /** Returns the amount the given count is above the minimum amount needed to fulfill this request */ - int surplusGiven(int count); + /** Returns the ideal number of nodes that should be retired to fulfill this spec */ + int idealRetiredCount(int acceptedCount, int currentRetiredCount); /** Returns a specification of a fraction of all the nodes of this. It is assumed the argument is a valid divisor. */ NodeSpec fraction(int divisor); @@ -97,7 +97,7 @@ public interface NodeSpec { public boolean saturatedBy(int count) { return fulfilledBy(count); } // min=max for count specs @Override - public int surplusGiven(int count) { return count - this.count; } + public int idealRetiredCount(int acceptedCount, int currentRetiredCount) { return acceptedCount - this.count; } @Override public NodeSpec fraction(int divisor) { return new CountNodeSpec(count/divisor, requestedFlavor); } @@ -152,7 +152,14 @@ public interface NodeSpec { public boolean saturatedBy(int count) { return false; } @Override - public int surplusGiven(int count) { return 0; } + public int idealRetiredCount(int acceptedCount, int currentRetiredCount) { + /* + * All nodes marked with wantToRetire get marked as retired just before this function is called, + * the job of this function is to throttle the retired count. If no nodes are marked as retired + * then continue this way, otherwise allow only 1 node to be retired + */ + return Math.min(1, currentRetiredCount); + } @Override public NodeSpec fraction(int divisor) { return this; } |