summaryrefslogtreecommitdiffstats
path: root/config-provisioning
diff options
context:
space:
mode:
authorHåkon Hallingstad <hakon@yahooinc.com>2024-05-18 23:38:02 +0200
committerHåkon Hallingstad <hakon@yahooinc.com>2024-05-18 23:38:02 +0200
commitdec25d5ab61a9e574a8b41853caa879adfccf894 (patch)
tree2f030b67856c39dff2a1448beaf5f9ef8040d6a5 /config-provisioning
parent922b703f5d73244b5be1b4362c0193b76a501409 (diff)
Remove flags dependency from config-model
Diffstat (limited to 'config-provisioning')
-rw-r--r--config-provisioning/pom.xml6
-rw-r--r--config-provisioning/src/main/java/com/yahoo/config/provision/CapacityPolicies.java46
-rw-r--r--config-provisioning/src/main/java/com/yahoo/config/provision/Exclusivity.java15
-rw-r--r--config-provisioning/src/main/java/com/yahoo/config/provision/SharedHosts.java30
4 files changed, 54 insertions, 43 deletions
diff --git a/config-provisioning/pom.xml b/config-provisioning/pom.xml
index 63fb2f30ba6..75047ac8efa 100644
--- a/config-provisioning/pom.xml
+++ b/config-provisioning/pom.xml
@@ -54,12 +54,6 @@
</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/CapacityPolicies.java b/config-provisioning/src/main/java/com/yahoo/config/provision/CapacityPolicies.java
index dec2984846e..818a448187c 100644
--- a/config-provisioning/src/main/java/com/yahoo/config/provision/CapacityPolicies.java
+++ b/config-provisioning/src/main/java/com/yahoo/config/provision/CapacityPolicies.java
@@ -3,15 +3,11 @@ package com.yahoo.config.provision;
import com.yahoo.component.Version;
import com.yahoo.config.provision.NodeResources.DiskSpeed;
-import com.yahoo.vespa.flags.FlagSource;
-import com.yahoo.vespa.flags.PermanentFlags;
-import com.yahoo.vespa.flags.StringFlag;
import java.util.Map;
import java.util.TreeMap;
import static com.yahoo.config.provision.NodeResources.Architecture;
-import static com.yahoo.vespa.flags.Dimension.INSTANCE_ID;
import static java.util.Objects.requireNonNull;
/**
@@ -23,24 +19,26 @@ public class CapacityPolicies {
private final Zone zone;
private final Exclusivity exclusivity;
- private final StringFlag adminClusterNodeArchitecture;
+ private final ApplicationId applicationId;
+ private final Architecture adminClusterArchitecture;
- public CapacityPolicies(Zone zone, Exclusivity exclusivity, FlagSource flagSource) {
+ public CapacityPolicies(Zone zone, Exclusivity exclusivity, ApplicationId applicationId, Architecture adminClusterArchitecture) {
this.zone = zone;
this.exclusivity = exclusivity;
- this.adminClusterNodeArchitecture = PermanentFlags.ADMIN_CLUSTER_NODE_ARCHITECTURE.bindTo(flagSource);
+ this.applicationId = applicationId;
+ this.adminClusterArchitecture = adminClusterArchitecture;
}
- public Capacity applyOn(Capacity capacity, ApplicationId application, boolean exclusive) {
- var min = applyOn(capacity.minResources(), capacity, application, exclusive);
- var max = applyOn(capacity.maxResources(), capacity, application, exclusive);
+ public Capacity applyOn(Capacity capacity, boolean exclusive) {
+ var min = applyOn(capacity.minResources(), capacity, exclusive);
+ var max = applyOn(capacity.maxResources(), capacity, exclusive);
var groupSize = capacity.groupSize().fromAtMost(max.nodes() / min.groups())
.toAtLeast(min.nodes() / max.groups());
return capacity.withLimits(min, max, groupSize);
}
- private ClusterResources applyOn(ClusterResources resources, Capacity capacity, ApplicationId application, boolean exclusive) {
- int nodes = decideCount(resources.nodes(), capacity.isRequired(), application.instance().isTester());
+ private ClusterResources applyOn(ClusterResources resources, Capacity capacity, boolean exclusive) {
+ int nodes = decideCount(resources.nodes(), capacity.isRequired(), applicationId.instance().isTester());
int groups = decideGroups(resources.nodes(), resources.groups(), nodes);
var nodeResources = decideNodeResources(resources.nodeResources(), capacity.isRequired(), exclusive);
return new ClusterResources(nodes, groups, nodeResources);
@@ -85,31 +83,29 @@ public class CapacityPolicies {
return target;
}
- public ClusterResources specifyFully(ClusterResources resources, ClusterSpec clusterSpec, ApplicationId applicationId) {
- return resources.with(specifyFully(resources.nodeResources(), clusterSpec, applicationId));
+ public ClusterResources specifyFully(ClusterResources resources, ClusterSpec clusterSpec) {
+ return resources.with(specifyFully(resources.nodeResources(), clusterSpec));
}
- public NodeResources specifyFully(NodeResources resources, ClusterSpec clusterSpec, ApplicationId applicationId) {
- return resources.withUnspecifiedFieldsFrom(defaultResources(clusterSpec, applicationId).with(DiskSpeed.any));
+ public NodeResources specifyFully(NodeResources resources, ClusterSpec clusterSpec) {
+ return resources.withUnspecifiedFieldsFrom(defaultResources(clusterSpec).with(DiskSpeed.any));
}
- private NodeResources defaultResources(ClusterSpec clusterSpec, ApplicationId applicationId) {
+ private NodeResources defaultResources(ClusterSpec clusterSpec) {
if (clusterSpec.type() == ClusterSpec.Type.admin) {
- Architecture architecture = adminClusterArchitecture(applicationId);
-
if (exclusivity.allocation(clusterSpec)) {
- return smallestExclusiveResources().with(architecture);
+ return smallestExclusiveResources().with(adminClusterArchitecture);
}
if (clusterSpec.id().value().equals("cluster-controllers")) {
- return clusterControllerResources(clusterSpec, architecture).with(architecture);
+ return clusterControllerResources(clusterSpec, adminClusterArchitecture).with(adminClusterArchitecture);
}
if (clusterSpec.id().value().equals("logserver")) {
- return logserverResources(architecture).with(architecture);
+ return logserverResources(adminClusterArchitecture).with(adminClusterArchitecture);
}
- return versioned(clusterSpec, Map.of(new Version(0), smallestSharedResources())).with(architecture);
+ return versioned(clusterSpec, Map.of(new Version(0), smallestSharedResources())).with(adminClusterArchitecture);
}
if (clusterSpec.type() == ClusterSpec.Type.content) {
@@ -148,10 +144,6 @@ public class CapacityPolicies {
: new NodeResources(0.5, 2, 50, 0.3);
}
- private Architecture adminClusterArchitecture(ApplicationId instance) {
- return Architecture.valueOf(adminClusterNodeArchitecture.with(INSTANCE_ID, instance.serializedForm()).value());
- }
-
// The lowest amount of resources that can be exclusive allocated (i.e. a matching host flavor for this exists)
private NodeResources smallestExclusiveResources() {
return zone.cloud().name() == CloudName.AZURE || zone.cloud().name() == CloudName.GCP
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
index 40122c17c3f..6aafb20bee2 100644
--- a/config-provisioning/src/main/java/com/yahoo/config/provision/Exclusivity.java
+++ b/config-provisioning/src/main/java/com/yahoo/config/provision/Exclusivity.java
@@ -1,10 +1,5 @@
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.
*
@@ -13,16 +8,16 @@ import com.yahoo.vespa.flags.custom.SharedHost;
public class Exclusivity {
private final Zone zone;
- private final JacksonFlag<SharedHost> sharedHosts;
+ private final SharedHosts sharedHost;
- public Exclusivity(Zone zone, FlagSource flagSource) {
+ public Exclusivity(Zone zone, SharedHosts sharedHost) {
this.zone = zone;
- this.sharedHosts = PermanentFlags.SHARED_HOST.bindTo(flagSource);
+ this.sharedHost = sharedHost;
}
/** 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());
+ return sharedHost.hasClusterType(cluster.type());
}
/** Returns whether the nodes of this cluster must be running on hosts that are specifically provisioned for the application. */
@@ -38,7 +33,7 @@ public class Exclusivity {
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()));
+ ( !zone.cloud().allowHostSharing() && !sharedHost.supportsClusterType(clusterSpec.type()));
}
}
diff --git a/config-provisioning/src/main/java/com/yahoo/config/provision/SharedHosts.java b/config-provisioning/src/main/java/com/yahoo/config/provision/SharedHosts.java
new file mode 100644
index 00000000000..44a91d2861d
--- /dev/null
+++ b/config-provisioning/src/main/java/com/yahoo/config/provision/SharedHosts.java
@@ -0,0 +1,30 @@
+package com.yahoo.config.provision;
+
+import com.fasterxml.jackson.annotation.JsonIgnore;
+
+/**
+ * @author hakonhall
+ */
+public interface SharedHosts {
+ static SharedHosts empty() {
+ return new SharedHosts() {
+ @Override public boolean supportsClusterType(ClusterSpec.Type clusterType) { return false; }
+ @Override public boolean hasClusterType(ClusterSpec.Type clusterType) { return false; }
+ };
+ }
+
+ static SharedHosts ofConstant(boolean supportsClusterType, boolean hasClusterType) {
+ return new SharedHosts() {
+ @Override public boolean supportsClusterType(ClusterSpec.Type clusterType) { return supportsClusterType; }
+ @Override public boolean hasClusterType(ClusterSpec.Type clusterType) { return hasClusterType; }
+ };
+ }
+
+ /** Whether there are any shared hosts specifically for the given cluster type, or without a cluster type restriction. */
+ @JsonIgnore
+ boolean supportsClusterType(ClusterSpec.Type clusterType);
+
+ /** Whether there are any shared hosts specifically for the given cluster type. */
+ @JsonIgnore
+ boolean hasClusterType(ClusterSpec.Type clusterType);
+}