diff options
author | Jon Bratseth <bratseth@vespa.ai> | 2024-04-21 12:22:56 +0200 |
---|---|---|
committer | Jon Bratseth <bratseth@vespa.ai> | 2024-04-21 12:22:56 +0200 |
commit | cbd1ec977decd5cd80777da34c68589d6d78162e (patch) | |
tree | ee5e1a5ab1605fe26bde1bde1ef99fe45194d4df /node-repository | |
parent | d0349764f69b89e689a971f9ba2de0cc564ceba9 (diff) |
Cleanup
Diffstat (limited to 'node-repository')
3 files changed, 20 insertions, 12 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 cdf3b9233d5..1f75c4da5c6 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 @@ -53,8 +53,6 @@ class NodeAllocation { /** The requested nodes of this list */ private final NodeSpec requested; - private final int extraNodesNeeded; - /** The node candidates this has accepted so far, keyed on hostname */ public final Map<String, NodeCandidate> nodes = new LinkedHashMap<>(); @@ -88,12 +86,11 @@ class NodeAllocation { private final Optional<String> requiredHostFlavor; NodeAllocation(NodeList allNodes, ApplicationId application, ClusterSpec cluster, NodeSpec requested, - int extraNodesNeeded, Supplier<Integer> nextIndex, NodeRepository nodeRepository) { + Supplier<Integer> nextIndex, NodeRepository nodeRepository) { this.allNodes = allNodes; this.application = application; this.cluster = cluster; this.requested = requested; - this.extraNodesNeeded = extraNodesNeeded; this.nextIndex = nextIndex; this.nodeRepository = nodeRepository; this.requiredHostFlavor = Optional.of(PermanentFlags.HOST_FLAVOR.bindTo(nodeRepository.flagSource()) @@ -309,7 +306,7 @@ class NodeAllocation { /** Returns true if no more nodes are needed in this list */ public boolean saturated() { - return requested.saturatedBy(acceptedAndCompatible - extraNodesNeeded); + return requested.saturatedBy(acceptedAndCompatible); } /** Returns true if the content of this list is sufficient to meet the request */ @@ -423,7 +420,7 @@ class NodeAllocation { /** Returns the number of nodes accepted this far */ private int acceptedAndCompatibleOrResizable() { - if (nodeType() == NodeType.tenant) return acceptedAndCompatibleOrResizable - extraNodesNeeded; // xxx + if (nodeType() == NodeType.tenant) return acceptedAndCompatibleOrResizable; // Infrastructure nodes are always allocated by type. Count all nodes as accepted so that we never exceed // the wanted number of nodes for the type. return allNodes.nodeType(nodeType()).size(); 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 cb50f6dff2b..c599e7fd1f0 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 @@ -80,9 +80,11 @@ public interface NodeSpec { return false; } + NodeSpec withExtra(int nodeCount); + static NodeSpec from(int nodeCount, int groupCount, NodeResources resources, boolean exclusive, boolean canFail, CloudAccount cloudAccount, Duration hostTTL) { - return new CountNodeSpec(nodeCount, groupCount, resources, exclusive, canFail, canFail, cloudAccount, hostTTL); + return new CountNodeSpec(nodeCount, groupCount, resources, 0, exclusive, canFail, canFail, cloudAccount, hostTTL); } static NodeSpec from(NodeType type, CloudAccount cloudAccount) { @@ -95,17 +97,20 @@ public interface NodeSpec { private final int count; private final int groups; private final NodeResources requestedNodeResources; + private final int extraNodesNeeded; private final boolean exclusive; private final boolean canFail; private final boolean considerRetiring; private final CloudAccount cloudAccount; private final Duration hostTTL; - private CountNodeSpec(int count, int groups, NodeResources resources, boolean exclusive, boolean canFail, + private CountNodeSpec(int count, int groups, NodeResources resources, int extraNodesNeeded, + boolean exclusive, boolean canFail, boolean considerRetiring, CloudAccount cloudAccount, Duration hostTTL) { this.count = count; this.groups = groups; this.requestedNodeResources = Objects.requireNonNull(resources, "Resources must be specified"); + this.extraNodesNeeded = extraNodesNeeded; // ... due to reducing group size this.exclusive = exclusive; this.canFail = canFail; this.considerRetiring = considerRetiring; @@ -148,11 +153,11 @@ public interface NodeSpec { @Override public int fulfilledDeficitCount(int count) { - return Math.max(this.count - count, 0); + return Math.max(this.count + extraNodesNeeded - count, 0); } public NodeSpec withoutRetiring() { - return new CountNodeSpec(count, groups, requestedNodeResources, exclusive, canFail, false, cloudAccount, hostTTL); + return new CountNodeSpec(count, groups, requestedNodeResources, extraNodesNeeded, exclusive, canFail, false, cloudAccount, hostTTL); } @Override @@ -186,6 +191,10 @@ public interface NodeSpec { @Override public Duration hostTTL() { return hostTTL; } + public NodeSpec withExtra(int nodeCount) { + return new CountNodeSpec(count, groups, requestedNodeResources, nodeCount, exclusive, canFail, considerRetiring, cloudAccount, hostTTL); + } + @Override public String toString() { return "request for " + count + " nodes" + @@ -259,6 +268,8 @@ public interface NodeSpec { return cloudAccount; } + public NodeSpec withExtra(int nodeCount) { return this; } + @Override public String toString() { return "request for nodes of type '" + type + "'"; } diff --git a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/provisioning/Preparer.java b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/provisioning/Preparer.java index f1c84be324e..ea8e7d7db6e 100644 --- a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/provisioning/Preparer.java +++ b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/provisioning/Preparer.java @@ -188,8 +188,8 @@ public class Preparer { private NodeAllocation prepareAllocation(ApplicationId application, ClusterSpec cluster, NodeSpec requested, Supplier<Integer> nextIndex, LockedNodeList allNodes) { validateAccount(requested.cloudAccount(), application, allNodes); - int extraNodesNeeded = extraNodesNeeded(application, cluster, requested, allNodes); - NodeAllocation allocation = new NodeAllocation(allNodes, application, cluster, requested, extraNodesNeeded, nextIndex, nodeRepository); + requested = requested.withExtra(extraNodesNeeded(application, cluster, requested, allNodes)); + NodeAllocation allocation = new NodeAllocation(allNodes, application, cluster, requested, nextIndex, nodeRepository); IP.Allocation.Context allocationContext = IP.Allocation.Context.from(nodeRepository.zone().cloud().name(), requested.cloudAccount().isExclave(nodeRepository.zone()), nodeRepository.nameResolver()); |