aboutsummaryrefslogtreecommitdiffstats
path: root/config-provisioning/src/main/java/com/yahoo
diff options
context:
space:
mode:
authorJon Bratseth <bratseth@vespa.ai>2024-05-12 18:12:02 +0200
committerJon Bratseth <bratseth@vespa.ai>2024-05-12 18:12:02 +0200
commit7783175c9a82f175f589610e0cdf61ccc3c993db (patch)
tree64123bb7f336254f14069d34f81586ad158768eb /config-provisioning/src/main/java/com/yahoo
parent2721b3e11d361a01e36cc4030792d3daea01c740 (diff)
Move exclusivity decisions to config-provisioning
Diffstat (limited to 'config-provisioning/src/main/java/com/yahoo')
-rw-r--r--config-provisioning/src/main/java/com/yahoo/config/provision/Exclusivity.java44
1 files changed, 44 insertions, 0 deletions
diff --git a/config-provisioning/src/main/java/com/yahoo/config/provision/Exclusivity.java b/config-provisioning/src/main/java/com/yahoo/config/provision/Exclusivity.java
new file mode 100644
index 00000000000..40122c17c3f
--- /dev/null
+++ b/config-provisioning/src/main/java/com/yahoo/config/provision/Exclusivity.java
@@ -0,0 +1,44 @@
+package com.yahoo.config.provision;
+
+import com.yahoo.vespa.flags.FlagSource;
+import com.yahoo.vespa.flags.JacksonFlag;
+import com.yahoo.vespa.flags.PermanentFlags;
+import com.yahoo.vespa.flags.custom.SharedHost;
+
+/**
+ * A class which can be asked if allocations should be exclusive.
+ *
+ * @author bratseth
+ */
+public class Exclusivity {
+
+ private final Zone zone;
+ private final JacksonFlag<SharedHost> sharedHosts;
+
+ public Exclusivity(Zone zone, FlagSource flagSource) {
+ this.zone = zone;
+ this.sharedHosts = PermanentFlags.SHARED_HOST.bindTo(flagSource);
+ }
+
+ /** Returns whether nodes must be allocated to hosts that are exclusive to the cluster type. */
+ public boolean clusterType(ClusterSpec cluster) {
+ return sharedHosts.value().hasClusterType(cluster.type().name());
+ }
+
+ /** Returns whether the nodes of this cluster must be running on hosts that are specifically provisioned for the application. */
+ public boolean provisioning(ClusterSpec clusterSpec) {
+ return !zone.cloud().allowHostSharing() && clusterSpec.isExclusive();
+ }
+
+ /**
+ * 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
+ * perfectly.
+ */
+ public boolean allocation(ClusterSpec clusterSpec) {
+ return clusterSpec.isExclusive() ||
+ ( clusterSpec.type().isContainer() && zone.system().isPublic() && !zone.environment().isTest() ) ||
+ ( !zone.cloud().allowHostSharing() && !sharedHosts.value().supportsClusterType(clusterSpec.type().name()));
+ }
+
+}