diff options
author | Jon Bratseth <bratseth@vespa.ai> | 2024-05-12 18:12:02 +0200 |
---|---|---|
committer | Jon Bratseth <bratseth@vespa.ai> | 2024-05-12 18:12:02 +0200 |
commit | 7783175c9a82f175f589610e0cdf61ccc3c993db (patch) | |
tree | 64123bb7f336254f14069d34f81586ad158768eb /config-provisioning | |
parent | 2721b3e11d361a01e36cc4030792d3daea01c740 (diff) |
Move exclusivity decisions to config-provisioning
Diffstat (limited to 'config-provisioning')
-rw-r--r-- | config-provisioning/pom.xml | 6 | ||||
-rw-r--r-- | config-provisioning/src/main/java/com/yahoo/config/provision/Exclusivity.java | 44 |
2 files changed, 50 insertions, 0 deletions
diff --git a/config-provisioning/pom.xml b/config-provisioning/pom.xml index 75047ac8efa..63fb2f30ba6 100644 --- a/config-provisioning/pom.xml +++ b/config-provisioning/pom.xml @@ -54,6 +54,12 @@ </dependency> <dependency> <groupId>com.yahoo.vespa</groupId> + <artifactId>flags</artifactId> + <version>${project.version}</version> + <scope>provided</scope> + </dependency> + <dependency> + <groupId>com.yahoo.vespa</groupId> <artifactId>testutil</artifactId> <version>${project.version}</version> <scope>test</scope> 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())); + } + +} |