diff options
author | Martin Polden <mpolden@mpolden.no> | 2023-08-30 11:14:04 +0200 |
---|---|---|
committer | Martin Polden <mpolden@mpolden.no> | 2023-08-30 15:16:58 +0200 |
commit | 40da844d9ab6765c9102931acd81a56860aef927 (patch) | |
tree | 1acee3b2f4551dbe0b57f6d9f2d6fa469fedf927 /controller-api/src/main/java/com | |
parent | 773644c6cac7a00aaaef3096ee52d1d87969e998 (diff) |
Precompute zone endpoints on deployment
Diffstat (limited to 'controller-api/src/main/java/com')
3 files changed, 47 insertions, 72 deletions
diff --git a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/application/v4/model/DeploymentData.java b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/application/v4/model/DeploymentData.java index f73aeb89f0e..d9384373deb 100644 --- a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/application/v4/model/DeploymentData.java +++ b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/application/v4/model/DeploymentData.java @@ -8,8 +8,6 @@ import com.yahoo.config.provision.DockerImage; import com.yahoo.config.provision.zone.ZoneId; import com.yahoo.vespa.athenz.api.AthenzDomain; import com.yahoo.vespa.hosted.controller.api.integration.billing.Quota; -import com.yahoo.vespa.hosted.controller.api.integration.certificates.EndpointCertificate; -import com.yahoo.vespa.hosted.controller.api.integration.configserver.ContainerEndpoint; import com.yahoo.vespa.hosted.controller.api.integration.dataplanetoken.DataplaneTokenVersions; import com.yahoo.vespa.hosted.controller.api.integration.secrets.TenantSecretStore; import com.yahoo.yolean.concurrent.Memoized; @@ -18,7 +16,6 @@ import java.io.InputStream; import java.security.cert.X509Certificate; import java.util.List; import java.util.Optional; -import java.util.Set; import java.util.function.Supplier; import static java.util.Objects.requireNonNull; @@ -35,8 +32,7 @@ public class DeploymentData { private final ZoneId zone; private final Supplier<InputStream> applicationPackage; private final Version platform; - private final Set<ContainerEndpoint> containerEndpoints; - private final Supplier<Optional<EndpointCertificate>> endpointCertificate; + private final Supplier<DeploymentEndpoints> endpoints; private final Optional<DockerImage> dockerImageRepo; private final Optional<AthenzDomain> athenzDomain; private final Supplier<Quota> quota; @@ -47,8 +43,7 @@ public class DeploymentData { private final boolean dryRun; public DeploymentData(ApplicationId instance, ZoneId zone, Supplier<InputStream> applicationPackage, Version platform, - Set<ContainerEndpoint> containerEndpoints, - Supplier<Optional<EndpointCertificate>> endpointCertificate, + Supplier<DeploymentEndpoints> endpoints, Optional<DockerImage> dockerImageRepo, Optional<AthenzDomain> athenzDomain, Supplier<Quota> quota, @@ -61,8 +56,7 @@ public class DeploymentData { this.zone = requireNonNull(zone); this.applicationPackage = requireNonNull(applicationPackage); this.platform = requireNonNull(platform); - this.containerEndpoints = Set.copyOf(requireNonNull(containerEndpoints)); - this.endpointCertificate = new Memoized<>(requireNonNull(endpointCertificate)); + this.endpoints = new Memoized<>(requireNonNull(endpoints)); this.dockerImageRepo = requireNonNull(dockerImageRepo); this.athenzDomain = athenzDomain; this.quota = new Memoized<>(requireNonNull(quota)); @@ -89,12 +83,8 @@ public class DeploymentData { return platform; } - public Set<ContainerEndpoint> containerEndpoints() { - return containerEndpoints; - } - - public Optional<EndpointCertificate> endpointCertificate() { - return endpointCertificate.get(); + public Supplier<DeploymentEndpoints> endpoints() { + return endpoints; } public Optional<DockerImage> dockerImageRepo() { diff --git a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/application/v4/model/DeploymentEndpoints.java b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/application/v4/model/DeploymentEndpoints.java new file mode 100644 index 00000000000..9ec17571a35 --- /dev/null +++ b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/application/v4/model/DeploymentEndpoints.java @@ -0,0 +1,25 @@ +// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +package com.yahoo.vespa.hosted.controller.api.application.v4.model; + +import com.yahoo.vespa.hosted.controller.api.integration.certificates.EndpointCertificate; +import com.yahoo.vespa.hosted.controller.api.integration.configserver.ContainerEndpoint; + +import java.util.Objects; +import java.util.Optional; +import java.util.Set; + +/** + * The endpoints and their certificate (if any) of a deployment. + * + * @author mpolden + */ +public record DeploymentEndpoints(Set<ContainerEndpoint> endpoints, Optional<EndpointCertificate> certificate) { + + public static final DeploymentEndpoints none = new DeploymentEndpoints(Set.of(), Optional.empty()); + + public DeploymentEndpoints { + Objects.requireNonNull(endpoints); + Objects.requireNonNull(certificate); + } + +} diff --git a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/configserver/ContainerEndpoint.java b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/configserver/ContainerEndpoint.java index 7246903a51b..4746fa2da26 100644 --- a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/configserver/ContainerEndpoint.java +++ b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/configserver/ContainerEndpoint.java @@ -1,79 +1,39 @@ // Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.vespa.hosted.controller.api.integration.configserver; +import com.yahoo.config.provision.zone.AuthMethod; import com.yahoo.config.provision.zone.RoutingMethod; import java.util.List; +import java.util.Map; import java.util.Objects; import java.util.OptionalInt; /** - * This represents a list of one or more names for a container cluster. + * The endpoint of a container cluster. This encapsulates the endpoint details passed from controller to the config + * server on deploy. + * + * @param clusterId ID of the cluster to which this points + * @param scope Scope of this endpoint + * @param names All valid DNS names for this endpoint. This can contain both proper DNS names and synthetic identifiers + * used for routing, such as a Host header value that is not necessarily a proper DNS name + * @param weight The relative weight of this endpoint + * @param routingMethod The routing method used by this endpoint + * @param authMethods Supported authentication methods for each endpoint name * * @author mpolden */ -public class ContainerEndpoint { - - private final String clusterId; - private final String scope; - private final List<String> names; - private final OptionalInt weight; - private final RoutingMethod routingMethod; +public record ContainerEndpoint(String clusterId, String scope, List<String> names, OptionalInt weight, + RoutingMethod routingMethod, Map<String, AuthMethod> authMethods) { - public ContainerEndpoint(String clusterId, String scope, List<String> names, OptionalInt weight, RoutingMethod routingMethod) { + public ContainerEndpoint(String clusterId, String scope, List<String> names, OptionalInt weight, + RoutingMethod routingMethod, Map<String, AuthMethod> authMethods) { this.clusterId = nonEmpty(clusterId, "clusterId must be non-empty"); this.scope = Objects.requireNonNull(scope, "scope must be non-null"); this.names = List.copyOf(Objects.requireNonNull(names, "names must be non-null")); this.weight = Objects.requireNonNull(weight, "weight must be non-null"); this.routingMethod = Objects.requireNonNull(routingMethod, "routingMethod must be non-null"); - } - - /** ID of the cluster to which this points */ - public String clusterId() { - return clusterId; - } - - /** The scope of this endpoint */ - public String scope() { - return scope; - } - - /** - * All valid DNS names for this endpoint. This can contain both proper DNS names and synthetic identifiers used for - * routing, such as a Host header value that is not necessarily a proper DNS name. - */ - public List<String> names() { - return names; - } - - /** The relative weight of this endpoint */ - public OptionalInt weight() { - return weight; - } - - /** The routing method used by this endpoint */ - public RoutingMethod routingMethod() { - return routingMethod; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - ContainerEndpoint that = (ContainerEndpoint) o; - return clusterId.equals(that.clusterId) && scope.equals(that.scope) && names.equals(that.names) && weight.equals(that.weight) && routingMethod == that.routingMethod; - } - - @Override - public int hashCode() { - return Objects.hash(clusterId, scope, names, weight, routingMethod); - } - - @Override - public String toString() { - return "container endpoint for cluster " + clusterId + ": " + String.join(", ", names) + - " [method=" + routingMethod + ",scope=" + scope + ",weight=" + - weight.stream().boxed().map(Object::toString).findFirst().orElse("<none>") + "]"; + this.authMethods = Objects.requireNonNull(Map.copyOf(authMethods), "authMethods must be non-null"); } private static String nonEmpty(String s, String message) { |