summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJon Bratseth <bratseth@oath.com>2019-10-30 22:39:50 +0100
committerGitHub <noreply@github.com>2019-10-30 22:39:50 +0100
commit44e3dda310c6848e086cef24fd90b8695d964205 (patch)
tree493d4025a4a3e64519f3937d302092c926fcf64f
parent96daedfffa69ef5ceb5630c4fb27f0aee29caee2 (diff)
parent9d27f575e60d0f644eabb6c474002b362216cf08 (diff)
Merge pull request #11162 from vespa-engine/bratseth/check-capacity-by-requested-resources
Check capacity by requested, not assigned resources
-rw-r--r--config-provisioning/src/main/java/com/yahoo/config/provision/InstanceName.java1
-rw-r--r--node-repository/src/main/java/com/yahoo/vespa/hosted/provision/maintenance/CapacityChecker.java40
2 files changed, 24 insertions, 17 deletions
diff --git a/config-provisioning/src/main/java/com/yahoo/config/provision/InstanceName.java b/config-provisioning/src/main/java/com/yahoo/config/provision/InstanceName.java
index e2733f31663..8eedd156779 100644
--- a/config-provisioning/src/main/java/com/yahoo/config/provision/InstanceName.java
+++ b/config-provisioning/src/main/java/com/yahoo/config/provision/InstanceName.java
@@ -8,7 +8,6 @@ import java.util.Objects;
* in order to provide a type safe API for defining environments.
*
* @author Ulf Lilleengen
- * @since 5.25
*/
public class InstanceName implements Comparable<InstanceName> {
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);
}