summaryrefslogtreecommitdiffstats
path: root/config-provisioning
diff options
context:
space:
mode:
authorjonmv <venstad@gmail.com>2022-11-18 15:30:01 +0100
committerjonmv <venstad@gmail.com>2022-11-24 17:11:07 +0100
commit5a97752f3261905015a50ad15062173e6438ff96 (patch)
tree121eed2895060f7321308b7c8e3236b6043417e7 /config-provisioning
parent22e91538da2029211bd9d640ec9e34e2fb3a8410 (diff)
Read load-balancer allowed URNs from container xml, wire to provisioner
Diffstat (limited to 'config-provisioning')
-rw-r--r--config-provisioning/src/main/java/com/yahoo/config/provision/ClusterSpec.java43
-rw-r--r--config-provisioning/src/main/java/com/yahoo/config/provision/LoadBalancerSettings.java18
2 files changed, 46 insertions, 15 deletions
diff --git a/config-provisioning/src/main/java/com/yahoo/config/provision/ClusterSpec.java b/config-provisioning/src/main/java/com/yahoo/config/provision/ClusterSpec.java
index dd07b29c2de..5fae9497f69 100644
--- a/config-provisioning/src/main/java/com/yahoo/config/provision/ClusterSpec.java
+++ b/config-provisioning/src/main/java/com/yahoo/config/provision/ClusterSpec.java
@@ -24,10 +24,12 @@ public final class ClusterSpec {
private final boolean exclusive;
private final Optional<Id> combinedId;
private final Optional<DockerImage> dockerImageRepo;
+ private final LoadBalancerSettings loadBalancerSettings;
private final boolean stateful;
private ClusterSpec(Type type, Id id, Optional<Group> groupId, Version vespaVersion, boolean exclusive,
- Optional<Id> combinedId, Optional<DockerImage> dockerImageRepo, boolean stateful) {
+ Optional<Id> combinedId, Optional<DockerImage> dockerImageRepo,
+ LoadBalancerSettings loadBalancerSettings, boolean stateful) {
this.type = type;
this.id = id;
this.groupId = groupId;
@@ -45,6 +47,7 @@ public final class ClusterSpec {
if (type.isContent() && !stateful) {
throw new IllegalArgumentException("Cluster of type " + type + " must be stateful");
}
+ this.loadBalancerSettings = Objects.requireNonNull(loadBalancerSettings);
this.stateful = stateful;
}
@@ -60,6 +63,9 @@ public final class ClusterSpec {
/** Returns the docker image (repository + vespa version) we want this cluster to run */
public Optional<String> dockerImage() { return dockerImageRepo.map(repo -> repo.withTag(vespaVersion).asString()); }
+ /** Returns any additional load balancer settings for application container clusters. */
+ public LoadBalancerSettings loadBalancerSettings() { return loadBalancerSettings; }
+
/** Returns the version of Vespa that we want this cluster to run */
public Version vespaVersion() { return vespaVersion; }
@@ -81,11 +87,11 @@ public final class ClusterSpec {
public boolean isStateful() { return stateful; }
public ClusterSpec with(Optional<Group> newGroup) {
- return new ClusterSpec(type, id, newGroup, vespaVersion, exclusive, combinedId, dockerImageRepo, stateful);
+ return new ClusterSpec(type, id, newGroup, vespaVersion, exclusive, combinedId, dockerImageRepo, loadBalancerSettings, stateful);
}
public ClusterSpec exclusive(boolean exclusive) {
- return new ClusterSpec(type, id, groupId, vespaVersion, exclusive, combinedId, dockerImageRepo, stateful);
+ return new ClusterSpec(type, id, groupId, vespaVersion, exclusive, combinedId, dockerImageRepo, loadBalancerSettings, stateful);
}
/** Creates a ClusterSpec when requesting a cluster */
@@ -103,13 +109,14 @@ public final class ClusterSpec {
private final Type type;
private final Id id;
private final boolean specification;
- private boolean stateful;
private Optional<Group> groupId = Optional.empty();
private Optional<DockerImage> dockerImageRepo = Optional.empty();
private Version vespaVersion;
private boolean exclusive = false;
private Optional<Id> combinedId = Optional.empty();
+ private LoadBalancerSettings loadBalancerSettings = LoadBalancerSettings.empty;
+ private boolean stateful;
private Builder(Type type, Id id, boolean specification) {
this.type = type;
@@ -124,7 +131,7 @@ public final class ClusterSpec {
if (vespaVersion == null) throw new IllegalArgumentException("vespaVersion is required to be set when creating a ClusterSpec with specification()");
} else
if (groupId.isPresent()) throw new IllegalArgumentException("groupId is not allowed to be set when creating a ClusterSpec with request()");
- return new ClusterSpec(type, id, groupId, vespaVersion, exclusive, combinedId, dockerImageRepo, stateful);
+ return new ClusterSpec(type, id, groupId, vespaVersion, exclusive, combinedId, dockerImageRepo, loadBalancerSettings, stateful);
}
public Builder group(Group groupId) {
@@ -157,6 +164,11 @@ public final class ClusterSpec {
return this;
}
+ public Builder loadBalancerSettings(LoadBalancerSettings loadBalancerSettings) {
+ this.loadBalancerSettings = loadBalancerSettings;
+ return this;
+ }
+
public Builder stateful(boolean stateful) {
this.stateful = stateful;
return this;
@@ -181,12 +193,13 @@ public final class ClusterSpec {
groupId.equals(that.groupId) &&
vespaVersion.equals(that.vespaVersion) &&
combinedId.equals(that.combinedId) &&
- dockerImageRepo.equals(that.dockerImageRepo);
+ dockerImageRepo.equals(that.dockerImageRepo) &&
+ loadBalancerSettings.equals(that.loadBalancerSettings);
}
@Override
public int hashCode() {
- return Objects.hash(type, id, groupId, vespaVersion, exclusive, combinedId, dockerImageRepo, stateful);
+ return Objects.hash(type, id, groupId, vespaVersion, exclusive, combinedId, dockerImageRepo, loadBalancerSettings, stateful);
}
/**
@@ -203,7 +216,7 @@ public final class ClusterSpec {
/** A cluster type */
public enum Type {
- // These enum values are stored in ZooKeeper - do not change
+ // These enum names are written to ZooKeeper - do not change
admin,
container,
content,
@@ -220,13 +233,13 @@ public final class ClusterSpec {
}
public static Type from(String typeName) {
- switch (typeName) {
- case "admin" : return admin;
- case "container" : return container;
- case "content" : return content;
- case "combined" : return combined;
- default: throw new IllegalArgumentException("Illegal cluster type '" + typeName + "'");
- }
+ return switch (typeName) {
+ case "admin" -> admin;
+ case "container" -> container;
+ case "content" -> content;
+ case "combined" -> combined;
+ default -> throw new IllegalArgumentException("Illegal cluster type '" + typeName + "'");
+ };
}
}
diff --git a/config-provisioning/src/main/java/com/yahoo/config/provision/LoadBalancerSettings.java b/config-provisioning/src/main/java/com/yahoo/config/provision/LoadBalancerSettings.java
new file mode 100644
index 00000000000..38a48363f3c
--- /dev/null
+++ b/config-provisioning/src/main/java/com/yahoo/config/provision/LoadBalancerSettings.java
@@ -0,0 +1,18 @@
+package com.yahoo.config.provision;
+
+import java.util.List;
+
+/**
+ * Settings for a load balancer provisioned for an application container cluster.
+ *
+ * @author jonmv
+ */
+public record LoadBalancerSettings(List<String> allowedUrns) {
+
+ public static final LoadBalancerSettings empty = new LoadBalancerSettings(List.of());
+
+ public LoadBalancerSettings(List<String> allowedUrns) {
+ this.allowedUrns = List.copyOf(allowedUrns);
+ }
+
+}