diff options
author | Jon Bratseth <bratseth@verizonmedia.com> | 2019-10-30 15:54:32 +0100 |
---|---|---|
committer | Jon Bratseth <bratseth@verizonmedia.com> | 2019-10-30 15:54:32 +0100 |
commit | 9d27f575e60d0f644eabb6c474002b362216cf08 (patch) | |
tree | 8bb3cc82660da98873b4586fef908d0ea241be9d /node-repository | |
parent | 1cd1a069f9e8e3b148331d8ac9ea26e52475c274 (diff) |
Check capacity by requested, not assigned resources
Diffstat (limited to 'node-repository')
-rw-r--r-- | node-repository/src/main/java/com/yahoo/vespa/hosted/provision/maintenance/CapacityChecker.java | 40 |
1 files changed, 24 insertions, 16 deletions
diff --git a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/maintenance/CapacityChecker.java b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/maintenance/CapacityChecker.java index 03cd3dd4019..36f4c8759fd 100644 --- a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/maintenance/CapacityChecker.java +++ b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/maintenance/CapacityChecker.java @@ -145,11 +145,12 @@ public class CapacityChecker { * Computes a heuristic for each host, with a lower score indicating a higher perceived likelihood that removing * the host causes an unrecoverable state */ - private Map<Node, Integer> computeMaximalRepeatedRemovals(List<Node> hosts, Map<Node, List<Node>> nodeChildren, + private Map<Node, Integer> computeMaximalRepeatedRemovals(List<Node> hosts, + Map<Node, List<Node>> nodeChildren, Map<Node, AllocationResources> availableResources) { Map<Node, Integer> timesNodeCanBeRemoved = hosts.stream().collect(Collectors.toMap( Function.identity(), - _x -> Integer.MAX_VALUE + __ -> Integer.MAX_VALUE )); for (Node host : hosts) { List<Node> children = nodeChildren.get(host); @@ -159,7 +160,7 @@ public class CapacityChecker { int timesHostCanBeRemoved = 0; Optional<Node> unallocatedNode; - while (timesHostCanBeRemoved < 1000) { // Arbritrary upper bound + while (timesHostCanBeRemoved < 1000) { // Arbitrary upper bound unallocatedNode = tryAllocateNodes(nodeChildren.get(host), hosts, resourceMap, containedAllocations); if (unallocatedNode.isEmpty()) { timesHostCanBeRemoved++; @@ -225,13 +226,15 @@ public class CapacityChecker { /** * Attempts to allocate the listed nodes to a new host, mutating availableResources and containedAllocations, * optionally returning the first node to fail, if one does. - * */ - private Optional<Node> tryAllocateNodes(List<Node> nodes, List<Node> hosts, + */ + private Optional<Node> tryAllocateNodes(List<Node> nodes, + List<Node> hosts, Map<Node, AllocationResources> availableResources, Map<Node, List<Allocation>> containedAllocations) { return tryAllocateNodes(nodes, hosts, availableResources, containedAllocations, false); } - private Optional<Node> tryAllocateNodes(List<Node> nodes, List<Node> hosts, + private Optional<Node> tryAllocateNodes(List<Node> nodes, + List<Node> hosts, Map<Node, AllocationResources> availableResources, Map<Node, List<Allocation>> containedAllocations, boolean withHistory) { for (var node : nodes) { @@ -251,13 +254,12 @@ public class CapacityChecker { return Optional.empty(); } - /** - * @return The parent to which the node was allocated, if it was successfully allocated. - */ - private Optional<Node> tryAllocateNode(Node node, List<Node> hosts, - Map<Node, AllocationResources> availableResources, - Map<Node, List<Allocation>> containedAllocations) { - AllocationResources requiredNodeResources = AllocationResources.from(node.flavor().resources()); + /** Returns the parent to which the node was allocated, if it was successfully allocated. */ + private Optional<Node> tryAllocateNode(Node node, + List<Node> hosts, + Map<Node, AllocationResources> availableResources, + Map<Node, List<Allocation>> containedAllocations) { + AllocationResources requiredNodeResources = AllocationResources.from(node); for (var host : hosts) { var availableHostResources = availableResources.get(host); if (violatesParentHostPolicy(node, host, containedAllocations)) { @@ -366,13 +368,19 @@ public class CapacityChecker { } } - /** - * Used to describe the resources required for a tenant, and available to a host. - */ + /** Used to describe the resources required for a tenant, and available to a host. */ private static class AllocationResources { + NodeResources nodeResources; int availableIPs; + public static AllocationResources from(Node node) { + if (node.allocation().isPresent()) + return from(node.allocation().get().requestedResources()); + else + return from(node.flavor().resources()); + } + public static AllocationResources from(NodeResources nodeResources) { return new AllocationResources(nodeResources, 1); } |