aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHåkon Hallingstad <hakon@yahooinc.com>2023-10-26 10:48:12 +0200
committerHåkon Hallingstad <hakon@yahooinc.com>2023-10-26 10:48:12 +0200
commit7e5c04bf7c3e30036a5294b2298f805f48bed4a0 (patch)
tree7f82de723ee19d7b378cd03d292585ebf397832b
parent444b2217bc11103d01a1262c9baa84ee3a4eb4ef (diff)
Rename requireParentHostLock to canMakeHostExclusive
-rw-r--r--node-repository/src/main/java/com/yahoo/vespa/hosted/provision/provisioning/NodeCandidate.java10
-rw-r--r--node-repository/src/main/java/com/yahoo/vespa/hosted/provision/provisioning/Preparer.java10
2 files changed, 10 insertions, 10 deletions
diff --git a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/provisioning/NodeCandidate.java b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/provisioning/NodeCandidate.java
index 179d88d33ab..1547a266e15 100644
--- a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/provisioning/NodeCandidate.java
+++ b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/provisioning/NodeCandidate.java
@@ -628,7 +628,7 @@ public abstract class NodeCandidate implements Nodelike, Comparable<NodeCandidat
// this cluster requires exclusivity, but the parent is not exclusive
if (exclusiveAllocation && parent.flatMap(Node::exclusiveToApplicationId).isEmpty())
- return Preparer.requireParentHostLock(makeExclusive, type(), hostSharing) ?
+ return canMakeHostExclusive(makeExclusive, type(), hostSharing) ?
ExclusivityViolation.PARENT_HOST_NOT_EXCLUSIVE :
ExclusivityViolation.YES;
}
@@ -636,4 +636,12 @@ public abstract class NodeCandidate implements Nodelike, Comparable<NodeCandidat
return ExclusivityViolation.NONE;
}
+ /**
+ * Whether it is allowed to take a host not exclusive to anyone, and make it exclusive to an application.
+ * Returns false if {@code makeExclusive} is false, which can be used to guard this feature.
+ */
+ public static boolean canMakeHostExclusive(boolean makeExclusive, NodeType type, boolean allowHostSharing) {
+ return makeExclusive && type == NodeType.tenant && !allowHostSharing;
+ }
+
}
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 17ff3b99e0c..270fda8314e 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
@@ -93,16 +93,8 @@ public class Preparer {
}
}
- /**
- * Whether the preparation of an application MAY require changes to the parent hosts, and therefore the parent host lock is required.
- * See {@link NodeCandidate#withExclusiveParent(boolean)}.
- */
- public static boolean requireParentHostLock(boolean makeExclusive, NodeType type, boolean allowHostSharing) {
- return makeExclusive && type == NodeType.tenant && !allowHostSharing;
- }
-
private ApplicationMutex parentLockOrNull(boolean makeExclusive, NodeType type) {
- return requireParentHostLock(makeExclusive, type, nodeRepository.zone().cloud().allowHostSharing()) ?
+ return NodeCandidate.canMakeHostExclusive(makeExclusive, type, nodeRepository.zone().cloud().allowHostSharing()) ?
nodeRepository.applications().lock(InfrastructureApplication.withNodeType(type.parentNodeType()).id()) :
null;
}