diff options
Diffstat (limited to 'config-provisioning/src/main/java')
4 files changed, 36 insertions, 16 deletions
diff --git a/config-provisioning/src/main/java/com/yahoo/config/provision/ClusterMembership.java b/config-provisioning/src/main/java/com/yahoo/config/provision/ClusterMembership.java index 9e8388b6442..7de3d41817a 100644 --- a/config-provisioning/src/main/java/com/yahoo/config/provision/ClusterMembership.java +++ b/config-provisioning/src/main/java/com/yahoo/config/provision/ClusterMembership.java @@ -22,16 +22,28 @@ public class ClusterMembership { private ClusterMembership(String stringValue, Version vespaVersion, Optional<DockerImage> dockerImageRepo, ZoneEndpoint zoneEndpoint) { String[] components = stringValue.split("/"); - if (components.length < 4) + if (components.length < 3) throw new RuntimeException("Could not parse '" + stringValue + "' to a cluster membership. " + "Expected 'clusterType/clusterId/groupId/index[/retired][/exclusive][/stateful][/combinedId]'"); + Integer groupIndex = components[2].isEmpty() ? null : Integer.parseInt(components[2]); + Integer nodeIndex; + int missingElements = 0; + try { + nodeIndex = Integer.parseInt(components[3]); + } catch (NumberFormatException | ArrayIndexOutOfBoundsException e) { + // Legacy form missing the group component + nodeIndex = groupIndex; + groupIndex = null; + missingElements = 1; + } + boolean exclusive = false; boolean stateful = false; var combinedId = Optional.<String>empty(); boolean retired = false; - if (components.length > 4) { - for (int i = 4; i < components.length; i++) { + if (components.length > (4 - missingElements)) { + for (int i = (4 - missingElements); i < components.length; i++) { String component = components[i]; switch (component) { case "exclusive" -> exclusive = true; @@ -44,7 +56,7 @@ public class ClusterMembership { this.cluster = ClusterSpec.specification(ClusterSpec.Type.valueOf(components[0]), ClusterSpec.Id.from(components[1])) - .group(ClusterSpec.Group.from(Integer.parseInt(components[2]))) + .group(groupIndex == null ? null : ClusterSpec.Group.from(groupIndex)) .vespaVersion(vespaVersion) .exclusive(exclusive) .combinedId(combinedId.map(ClusterSpec.Id::from)) @@ -52,7 +64,7 @@ public class ClusterMembership { .loadBalancerSettings(zoneEndpoint) .stateful(stateful) .build(); - this.index = Integer.parseInt(components[3]); + this.index = nodeIndex; this.retired = retired; this.stringValue = toStringValue(); } @@ -67,7 +79,7 @@ public class ClusterMembership { protected String toStringValue() { return cluster.type().name() + "/" + cluster.id().value() + - (cluster.group().isPresent() ? "/" + cluster.group().get().index() : "") + + (cluster.group().isPresent() ? "/" + cluster.group().get().index() : "/") + "/" + index + ( cluster.isExclusive() ? "/exclusive" : "") + ( retired ? "/retired" : "") + 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 ccc24e60edf..4a3045c9cdd 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 @@ -102,19 +102,18 @@ public final class ClusterSpec { /** Creates a ClusterSpec when requesting a cluster */ public static Builder request(Type type, Id id) { - return new Builder(type, id, false); + return new Builder(type, id); } /** Creates a ClusterSpec for an existing cluster, group id and Vespa version needs to be set */ public static Builder specification(Type type, Id id) { - return new Builder(type, id, true); + return new Builder(type, id); } public static class Builder { private final Type type; private final Id id; - private final boolean specification; private Optional<Group> groupId = Optional.empty(); private Optional<DockerImage> dockerImageRepo = Optional.empty(); @@ -124,19 +123,13 @@ public final class ClusterSpec { private ZoneEndpoint zoneEndpoint = ZoneEndpoint.defaultEndpoint; private boolean stateful; - private Builder(Type type, Id id, boolean specification) { + private Builder(Type type, Id id) { this.type = type; this.id = id; - this.specification = specification; this.stateful = type.isContent(); // Default to true for content clusters } public ClusterSpec build() { - if (specification) { - if (groupId.isEmpty()) throw new IllegalArgumentException("groupId is required to be set when creating a ClusterSpec with specification()"); - 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, zoneEndpoint, stateful); } diff --git a/config-provisioning/src/main/java/com/yahoo/config/provision/NodeAllocationException.java b/config-provisioning/src/main/java/com/yahoo/config/provision/NodeAllocationException.java index 507d95c1d7b..64d028db7b0 100644 --- a/config-provisioning/src/main/java/com/yahoo/config/provision/NodeAllocationException.java +++ b/config-provisioning/src/main/java/com/yahoo/config/provision/NodeAllocationException.java @@ -16,6 +16,11 @@ public class NodeAllocationException extends RuntimeException { this.retryable = retryable; } + public NodeAllocationException(String message, Throwable cause, boolean retryable) { + super(message, cause); + this.retryable = retryable; + } + public boolean retryable() { return retryable; } diff --git a/config-provisioning/src/main/java/com/yahoo/config/provision/ProvisionLogger.java b/config-provisioning/src/main/java/com/yahoo/config/provision/ProvisionLogger.java index 5a22056de1b..9d72f274419 100644 --- a/config-provisioning/src/main/java/com/yahoo/config/provision/ProvisionLogger.java +++ b/config-provisioning/src/main/java/com/yahoo/config/provision/ProvisionLogger.java @@ -10,6 +10,16 @@ import java.util.logging.Level; */ public interface ProvisionLogger { + /** Log a message unrelated to the application package, e.g. internal error/status. */ void log(Level level, String message); + /** + * Log a message related to the application package. These messages should be actionable by the user, f.ex. to + * signal usage of invalid/deprecated syntax. + * This default implementation just forwards to {@link #log(Level, String)} + */ + default void logApplicationPackage(Level level, String message) { + log(level, message); + } + } |