diff options
author | Håkon Hallingstad <hakon@yahooinc.com> | 2023-11-02 16:52:56 +0100 |
---|---|---|
committer | Håkon Hallingstad <hakon@yahooinc.com> | 2023-11-02 16:52:56 +0100 |
commit | b02d1228c2e0d957651c094a3af367d6229d2ae3 (patch) | |
tree | 84a4f16dbc1850385d48251253807cd8b2e3eb08 /node-repository | |
parent | ef89054d86570de1934d34e880b4827a310b9269 (diff) |
Retire if there are shared hosts dedicated to cluster type
Diffstat (limited to 'node-repository')
4 files changed, 13 insertions, 2 deletions
diff --git a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/NodeRepository.java b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/NodeRepository.java index 449e1c07bf8..dfbe41e31d7 100644 --- a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/NodeRepository.java +++ b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/NodeRepository.java @@ -201,6 +201,11 @@ public class NodeRepository extends AbstractComponent { /** The number of nodes we should ensure has free capacity for node failures whenever possible */ public int spareCount() { return spareCount; } + /** Returns whether nodes must be allocated to hosts that are exclusive to the cluster type. */ + public boolean exclusiveClusterType(ClusterSpec cluster) { + return sharedHosts.value().hasClusterType(cluster.type().name()); + } + /** * Returns whether nodes are allocated exclusively in this instance given this cluster spec. * Exclusive allocation requires that the wanted node resources matches the advertised resources of the node @@ -209,7 +214,7 @@ public class NodeRepository extends AbstractComponent { public boolean exclusiveAllocation(ClusterSpec clusterSpec) { return clusterSpec.isExclusive() || ( clusterSpec.type().isContainer() && zone.system().isPublic() && !zone.environment().isTest() ) || - ( !zone().cloud().allowHostSharing() && !sharedHosts.value().isEnabled(clusterSpec.type().name())); + ( !zone().cloud().allowHostSharing() && !sharedHosts.value().supportsClusterType(clusterSpec.type().name())); } /** Whether the nodes of this cluster must be running on hosts that are specifically provisioned for the application. */ diff --git a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/maintenance/HostCapacityMaintainer.java b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/maintenance/HostCapacityMaintainer.java index 3c42972ee0b..108f8d77837 100644 --- a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/maintenance/HostCapacityMaintainer.java +++ b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/maintenance/HostCapacityMaintainer.java @@ -301,6 +301,7 @@ public class HostCapacityMaintainer extends NodeRepositoryMaintainer { .stream() .filter(node -> node.violatesExclusivity(cluster, application, + nodeRepository().exclusiveClusterType(cluster), nodeRepository().exclusiveAllocation(cluster), false, nodeRepository().zone().cloud().allowHostSharing(), 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 e1be5b48e2d..21340baf273 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 @@ -198,6 +198,7 @@ class NodeAllocation { private NodeCandidate.ExclusivityViolation violatesExclusivity(NodeCandidate candidate) { return candidate.violatesExclusivity(cluster, application, + nodeRepository.exclusiveClusterType(cluster), nodeRepository.exclusiveAllocation(cluster), nodeRepository.exclusiveProvisioning(cluster), nodeRepository.zone().cloud().allowHostSharing(), allNodes, makeExclusive); 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 1547a266e15..8c29b40bc26 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 @@ -595,7 +595,7 @@ public abstract class NodeCandidate implements Nodelike, Comparable<NodeCandidat } public ExclusivityViolation violatesExclusivity(ClusterSpec cluster, ApplicationId application, - boolean exclusiveAllocation, boolean exclusiveProvisioning, + boolean exclusiveClusterType, boolean exclusiveAllocation, boolean exclusiveProvisioning, boolean hostSharing, NodeList allNodes, boolean makeExclusive) { if (parentHostname().isEmpty()) return ExclusivityViolation.NONE; if (type() != NodeType.tenant) return ExclusivityViolation.NONE; @@ -614,6 +614,10 @@ public abstract class NodeCandidate implements Nodelike, Comparable<NodeCandidat if ( ! emptyOrEqual(parent.flatMap(Node::exclusiveToClusterType), cluster.type())) return ExclusivityViolation.YES; + // this cluster requires a parent that was provisioned exclusively for this cluster type + if (exclusiveClusterType && parent.flatMap(Node::exclusiveToClusterType).isEmpty() && makeExclusive) + return ExclusivityViolation.YES; + // the parent is provisioned for another application if ( ! emptyOrEqual(parent.flatMap(Node::provisionedForApplicationId), application)) return ExclusivityViolation.YES; |