diff options
Diffstat (limited to 'node-repository/src')
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; } |