diff options
Diffstat (limited to 'config-provisioning/src/main')
4 files changed, 70 insertions, 18 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 0fb78b59aaf..0cd30061139 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 @@ -20,7 +20,7 @@ public class ClusterMembership { protected ClusterMembership() {} - private ClusterMembership(String stringValue, Version vespaVersion) { + private ClusterMembership(String stringValue, Version vespaVersion, Optional<String> dockerImageRepo) { String[] components = stringValue.split("/"); if (components.length < 4) throw new RuntimeException("Could not parse '" + stringValue + "' to a cluster membership. " + @@ -41,7 +41,7 @@ public class ClusterMembership { this.cluster = ClusterSpec.from(ClusterSpec.Type.valueOf(components[0]), ClusterSpec.Id.from(components[1]), ClusterSpec.Group.from(Integer.parseInt(components[2])), vespaVersion, - exclusive, combinedId.map(ClusterSpec.Id::from)); + exclusive, combinedId.map(ClusterSpec.Id::from), dockerImageRepo); this.index = Integer.parseInt(components[3]); this.stringValue = toStringValue(); } @@ -106,8 +106,14 @@ public class ClusterMembership { @Override public String toString() { return stringValue(); } + // TODO: Remove when when 7.195 is oldest model version in use + @Deprecated public static ClusterMembership from(String stringValue, Version vespaVersion) { - return new ClusterMembership(stringValue, vespaVersion); + return new ClusterMembership(stringValue, vespaVersion, Optional.empty()); + } + + public static ClusterMembership from(String stringValue, Version vespaVersion, Optional<String> dockerImageRepo) { + return new ClusterMembership(stringValue, vespaVersion, dockerImageRepo); } public static ClusterMembership from(ClusterSpec cluster, int index) { 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 afdae0023bc..af776a04a55 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 @@ -22,8 +22,10 @@ public final class ClusterSpec { private final Version vespaVersion; private boolean exclusive; private final Optional<Id> combinedId; + private final Optional<String> dockerImageRepo; - private ClusterSpec(Type type, Id id, Optional<Group> groupId, Version vespaVersion, boolean exclusive, Optional<Id> combinedId) { + private ClusterSpec(Type type, Id id, Optional<Group> groupId, Version vespaVersion, boolean exclusive, + Optional<Id> combinedId, Optional<String> dockerImageRepo) { this.type = type; this.id = id; this.groupId = groupId; @@ -34,6 +36,7 @@ public final class ClusterSpec { throw new IllegalArgumentException("combinedId must be empty for cluster of type " + type); } this.combinedId = combinedId; + this.dockerImageRepo = dockerImageRepo; } /** Returns the cluster type */ @@ -42,6 +45,9 @@ public final class ClusterSpec { /** Returns the cluster id */ public Id id() { return id; } + /** Returns the docker image repository part of a docker image we want this cluster to run */ + public Optional<String> dockerImageRepo() { return dockerImageRepo; } + /** Returns the version of Vespa that we want this cluster to run */ public Version vespaVersion() { return vespaVersion; } @@ -61,24 +67,42 @@ public final class ClusterSpec { public boolean isExclusive() { return exclusive; } public ClusterSpec with(Optional<Group> newGroup) { - return new ClusterSpec(type, id, newGroup, vespaVersion, exclusive, combinedId); + return new ClusterSpec(type, id, newGroup, vespaVersion, exclusive, combinedId, dockerImageRepo); } public ClusterSpec exclusive(boolean exclusive) { - return new ClusterSpec(type, id, groupId, vespaVersion, exclusive, combinedId); + return new ClusterSpec(type, id, groupId, vespaVersion, exclusive, combinedId, dockerImageRepo); + } + + // TODO: Remove when when 7.195 is oldest model version in use + // TODO: Add @Deprecated when internal repo has been updated to not use this method + // @Deprecated + public static ClusterSpec request(Type type, Id id, Version vespaVersion, boolean exclusive, + Optional<Id> combinedId) { + return request(type, id, vespaVersion, exclusive, combinedId, Optional.empty()); + } + + public static ClusterSpec request(Type type, Id id, Version vespaVersion, boolean exclusive, + Optional<Id> combinedId, Optional<String> dockerImageRepo) { + return new ClusterSpec(type, id, Optional.empty(), vespaVersion, exclusive, combinedId, dockerImageRepo); } - public static ClusterSpec request(Type type, Id id, Version vespaVersion, boolean exclusive, Optional<Id> combinedId) { - return new ClusterSpec(type, id, Optional.empty(), vespaVersion, exclusive, combinedId); + // TODO: Remove when when 7.195 is oldest model version in use + // TODO: Add @Deprecated when internal repo has been updated to not use this method + // @Deprecated + public static ClusterSpec from(Type type, Id id, Group groupId, Version vespaVersion, boolean exclusive, + Optional<Id> combinedId) { + return from(type, id, groupId, vespaVersion, exclusive, combinedId, Optional.empty()); } - public static ClusterSpec from(Type type, Id id, Group groupId, Version vespaVersion, boolean exclusive, Optional<Id> combinedId) { - return new ClusterSpec(type, id, Optional.of(groupId), vespaVersion, exclusive, combinedId); + public static ClusterSpec from(Type type, Id id, Group groupId, Version vespaVersion, boolean exclusive, + Optional<Id> combinedId, Optional<String> dockerImageRepo) { + return new ClusterSpec(type, id, Optional.of(groupId), vespaVersion, exclusive, combinedId, dockerImageRepo); } @Override public String toString() { - return type + " " + id + " " + groupId.map(group -> group + " ").orElse("") + vespaVersion; + return type + " " + id + " " + groupId.map(group -> group + " ").orElse("") + vespaVersion + " " + dockerImageRepo.orElse(""); } @Override @@ -93,6 +117,7 @@ public final class ClusterSpec { if ( ! other.id.equals(this.id)) return false; if ( ! other.groupId.equals(this.groupId)) return false; if ( ! other.vespaVersion.equals(this.vespaVersion)) return false; + if ( ! other.dockerImageRepo.orElse("").equals(this.dockerImageRepo.orElse(""))) return false; return true; } diff --git a/config-provisioning/src/main/java/com/yahoo/config/provision/HostSpec.java b/config-provisioning/src/main/java/com/yahoo/config/provision/HostSpec.java index 63725d9a535..4367e9750e6 100644 --- a/config-provisioning/src/main/java/com/yahoo/config/provision/HostSpec.java +++ b/config-provisioning/src/main/java/com/yahoo/config/provision/HostSpec.java @@ -1,6 +1,8 @@ // Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.config.provision; +import com.yahoo.component.Version; + import java.util.ArrayList; import java.util.List; import java.util.Objects; @@ -25,7 +27,9 @@ public class HostSpec implements Comparable<HostSpec> { private final Optional<Flavor> flavor; - private final Optional<com.yahoo.component.Version> version; + private final Optional<Version> version; + + private final Optional<String> dockerImageRepo; private final Optional<NetworkPorts> networkPorts; @@ -35,7 +39,7 @@ public class HostSpec implements Comparable<HostSpec> { this(hostname, new ArrayList<>(), Optional.empty(), membership); } - public HostSpec(String hostname, ClusterMembership membership, Flavor flavor, Optional<com.yahoo.component.Version> version) { + public HostSpec(String hostname, ClusterMembership membership, Flavor flavor, Optional<Version> version) { this(hostname, new ArrayList<>(), Optional.of(flavor), Optional.of(membership), version); } @@ -56,19 +60,26 @@ public class HostSpec implements Comparable<HostSpec> { } public HostSpec(String hostname, List<String> aliases, Optional<Flavor> flavor, - Optional<ClusterMembership> membership, Optional<com.yahoo.component.Version> version) { + Optional<ClusterMembership> membership, Optional<Version> version) { this(hostname, aliases, flavor, membership, version, Optional.empty()); } public HostSpec(String hostname, List<String> aliases, Optional<Flavor> flavor, - Optional<ClusterMembership> membership, Optional<com.yahoo.component.Version> version, + Optional<ClusterMembership> membership, Optional<Version> version, Optional<NetworkPorts> networkPorts) { this(hostname, aliases, flavor, membership, version, networkPorts, Optional.empty()); } public HostSpec(String hostname, List<String> aliases, Optional<Flavor> flavor, - Optional<ClusterMembership> membership, Optional<com.yahoo.component.Version> version, + Optional<ClusterMembership> membership, Optional<Version> version, Optional<NetworkPorts> networkPorts, Optional<NodeResources> requestedResources) { + this(hostname, aliases, flavor, membership, version, networkPorts, requestedResources, Optional.empty()); + } + + public HostSpec(String hostname, List<String> aliases, Optional<Flavor> flavor, + Optional<ClusterMembership> membership, Optional<Version> version, + Optional<NetworkPorts> networkPorts, Optional<NodeResources> requestedResources, + Optional<String> dockerImageRepo) { if (hostname == null || hostname.isEmpty()) throw new IllegalArgumentException("Hostname must be specified"); this.hostname = hostname; this.aliases = List.copyOf(aliases); @@ -77,6 +88,7 @@ public class HostSpec implements Comparable<HostSpec> { this.version = Objects.requireNonNull(version, "Version cannot be null but can be empty");; this.networkPorts = Objects.requireNonNull(networkPorts, "Network ports cannot be null but can be empty");; this.requestedResources = Objects.requireNonNull(requestedResources, "RequestedResources cannot be null"); + this.dockerImageRepo = Objects.requireNonNull(dockerImageRepo, "Version cannot be null but can be empty");; } /** Returns the name identifying this host */ @@ -99,8 +111,10 @@ public class HostSpec implements Comparable<HostSpec> { /** Returns the requested resources leading to this host being provisioned, or empty if not known */ public Optional<NodeResources> requestedResources() { return requestedResources; } + public Optional<String> dockerImageRepo() { return dockerImageRepo; } + public HostSpec withPorts(Optional<NetworkPorts> ports) { - return new HostSpec(hostname, aliases, flavor, membership, version, ports, requestedResources); + return new HostSpec(hostname, aliases, flavor, membership, version, ports, requestedResources, dockerImageRepo); } @Override diff --git a/config-provisioning/src/main/java/com/yahoo/config/provision/serialization/AllocatedHostsSerializer.java b/config-provisioning/src/main/java/com/yahoo/config/provision/serialization/AllocatedHostsSerializer.java index f66bacbc383..779dd1d24f7 100644 --- a/config-provisioning/src/main/java/com/yahoo/config/provision/serialization/AllocatedHostsSerializer.java +++ b/config-provisioning/src/main/java/com/yahoo/config/provision/serialization/AllocatedHostsSerializer.java @@ -59,6 +59,9 @@ public class AllocatedHostsSerializer { /** Wanted version */ private static final String hostSpecVespaVersionKey = "vespaVersion"; + /** Wanted docker image repo */ + private static final String hostSpecDockerImageRepoKey = "dockerImageRepo"; + /** Current version */ private static final String hostSpecCurrentVespaVersionKey = "currentVespaVersion"; private static final String hostSpecNetworkPortsKey = "ports"; @@ -79,6 +82,7 @@ public class AllocatedHostsSerializer { private static void toSlime(HostSpec host, Cursor object) { object.setString(hostSpecHostNameKey, host.hostname()); aliasesToSlime(host, object); + // TODO serialize dockerImageRepo host.membership().ifPresent(membership -> { object.setString(hostSpecMembershipKey, membership.stringValue()); object.setString(hostSpecVespaVersionKey, membership.cluster().vespaVersion().toFullString()); @@ -196,7 +200,10 @@ public class AllocatedHostsSerializer { private static ClusterMembership membershipFromSlime(Inspector object) { return ClusterMembership.from(object.field(hostSpecMembershipKey).asString(), - com.yahoo.component.Version.fromString(object.field(hostSpecVespaVersionKey).asString())); + com.yahoo.component.Version.fromString(object.field(hostSpecVespaVersionKey).asString()), + object.field(hostSpecDockerImageRepoKey).valid() + ? Optional.of(object.field(hostSpecDockerImageRepoKey).asString()) + : Optional.empty()); } private static Optional<String> optionalString(Inspector inspector) { |