summaryrefslogtreecommitdiffstats
path: root/node-repository/src
diff options
context:
space:
mode:
authorValerij Fredriksen <valerijf@verizonmedia.com>2020-10-30 10:48:23 +0100
committerValerij Fredriksen <valerijf@verizonmedia.com>2020-10-30 10:48:23 +0100
commit3db4dc08df8be6044d78373fd8d60fe3bf829bcc (patch)
treec8c6711d44be41472277ee8109a3c60804a831b7 /node-repository/src
parent697df3428e157243f64ea45a578150aece98506c (diff)
Simplify exclusivity check
Diffstat (limited to 'node-repository/src')
-rw-r--r--node-repository/src/main/java/com/yahoo/vespa/hosted/provision/provisioning/NodeAllocation.java43
1 files changed, 10 insertions, 33 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 1e98160955c..cb04ae578de 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
@@ -127,11 +127,7 @@ class NodeAllocation {
++rejectedDueToClashingParentHost;
continue;
}
- if ( ! exclusiveTo(application, candidate.parentHostname())) {
- ++rejectedDueToExclusivity;
- continue;
- }
- if ( requestedNodes.isExclusive() && ! hostsOnly(application, candidate.parentHostname())) {
+ if ( violatesExclusivity(candidate)) {
++rejectedDueToExclusivity;
continue;
}
@@ -158,7 +154,7 @@ class NodeAllocation {
if (violatesParentHostPolicy(candidate)) return true;
if ( ! hasCompatibleFlavor(candidate)) return true;
if (candidate.wantToRetire()) return true;
- if (requestedNodes.isExclusive() && ! hostsOnly(application, candidate.parentHostname())) return true;
+ if (violatesExclusivity(candidate)) return true;
return false;
}
@@ -182,35 +178,16 @@ class NodeAllocation {
return false;
}
- /**
- * If a parent host is given, and it hosts another application which requires exclusive access
- * to the physical host, then we cannot host this application on it.
- */
- private boolean exclusiveTo(ApplicationId applicationId, Optional<String> parentHostname) {
- if (parentHostname.isEmpty()) return true;
- for (Node nodeOnHost : allNodes.childrenOf(parentHostname.get())) {
- if (nodeOnHost.allocation().isEmpty()) continue;
- if ( nodeOnHost.allocation().get().membership().cluster().isExclusive() &&
- ! allocatedTo(applicationId, nodeOnHost))
- return false;
- }
- return true;
- }
-
- /** Returns true if this host only hosts the given application (in any instance) */
- private boolean hostsOnly(ApplicationId application, Optional<String> parentHostname) {
- if (parentHostname.isEmpty()) return true; // yes, as host is exclusive
-
- for (Node nodeOnHost : allNodes.childrenOf(parentHostname.get())) {
+ private boolean violatesExclusivity(NodeCandidate candidate) {
+ if (candidate.parentHostname().isEmpty()) return false;
+ for (Node nodeOnHost : allNodes.childrenOf(candidate.parentHostname().get())) {
if (nodeOnHost.allocation().isEmpty()) continue;
- if ( ! allocatedTo(application, nodeOnHost)) return false;
+ // If either this node or the other node on this host require exclusivity, they must have the same owner
+ if (requestedNodes.isExclusive() || nodeOnHost.allocation().get().membership().cluster().isExclusive()) {
+ if ( ! nodeOnHost.allocation().get().owner().equals(application)) return true;
+ }
}
- return true;
- }
-
- private boolean allocatedTo(ApplicationId applicationId, Node node) {
- if (node.allocation().isEmpty()) return false;
- return node.allocation().get().owner().equals(applicationId);
+ return false;
}
/**