diff options
author | Jon Marius Venstad <jonmv@users.noreply.github.com> | 2023-10-26 12:26:54 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-10-26 12:26:54 +0200 |
commit | 9e88b79e65c2f27eda569ee2fec4bde1401e9a59 (patch) | |
tree | bc3771afb9d7b888d00f679968dfd2008be472f0 | |
parent | 0f3fc1c12d97f92e7826e43af2ad1740a8390e17 (diff) | |
parent | 7e5c04bf7c3e30036a5294b2298f805f48bed4a0 (diff) |
Merge pull request #29110 from vespa-engine/hakonhall/rename-requireparenthostlock-to-canmakehostexclusive
Rename requireParentHostLock to canMakeHostExclusive
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; } |