diff options
author | jonmv <venstad@gmail.com> | 2022-11-15 19:03:02 +0100 |
---|---|---|
committer | jonmv <venstad@gmail.com> | 2022-11-16 09:34:36 +0100 |
commit | c1cd64bf28738f8550414c586b48d435ba9495de (patch) | |
tree | adad79d48ae03545b5a5a5fc5be123c1037466d5 | |
parent | 18c4b5ec5773ced34eb4700b54799963d74ed0ef (diff) |
Always hide regino part in application endpoints
11 files changed, 95 insertions, 135 deletions
diff --git a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/RoutingController.java b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/RoutingController.java index aeefc13b7c4..c4a3319c915 100644 --- a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/RoutingController.java +++ b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/RoutingController.java @@ -19,7 +19,6 @@ import com.yahoo.vespa.hosted.controller.api.integration.dns.Record; import com.yahoo.vespa.hosted.controller.api.integration.dns.RecordData; import com.yahoo.vespa.hosted.controller.api.integration.dns.RecordName; import com.yahoo.vespa.hosted.controller.application.Endpoint; -import com.yahoo.vespa.hosted.controller.application.Endpoint.EndpointFactory; import com.yahoo.vespa.hosted.controller.application.Endpoint.Port; import com.yahoo.vespa.hosted.controller.application.EndpointId; import com.yahoo.vespa.hosted.controller.application.EndpointList; @@ -72,7 +71,6 @@ public class RoutingController { private final Controller controller; private final RoutingPolicies routingPolicies; private final RotationRepository rotationRepository; - private final EndpointFactory endpointFactory; public RoutingController(Controller controller, RotationsConfig rotationsConfig) { this.controller = Objects.requireNonNull(controller, "controller must be non-null"); @@ -80,7 +78,6 @@ public class RoutingController { this.rotationRepository = new RotationRepository(Objects.requireNonNull(rotationsConfig, "rotationsConfig must be non-null"), controller.applications(), controller.curator()); - this.endpointFactory = new EndpointFactory(controller.zoneRegistry()); } /** Create a routing context for given deployment */ @@ -169,13 +166,13 @@ public class RoutingController { ZoneId zone = deployments.keySet().iterator().next().zoneId(); // Where multiple zones are possible, they all have the same routing method. // Application endpoints are only supported when using direct routing methods RoutingMethod routingMethod = usesSharedRouting(zone) ? RoutingMethod.sharedLayer4 : RoutingMethod.exclusive; - endpoints.add(endpointFactory.of(application.id()) - .targetApplication(EndpointId.of(declaredEndpoint.endpointId()), + endpoints.add(Endpoint.of(application.id()) + .targetApplication(EndpointId.of(declaredEndpoint.endpointId()), ClusterSpec.Id.from(declaredEndpoint.containerId()), deployments) - .routingMethod(routingMethod) - .on(Port.fromRoutingMethod(routingMethod)) - .in(controller.system())); + .routingMethod(routingMethod) + .on(Port.fromRoutingMethod(routingMethod)) + .in(controller.system())); } return EndpointList.copyOf(endpoints); } @@ -208,8 +205,8 @@ public class RoutingController { List<Endpoint.EndpointBuilder> builders = new ArrayList<>(); if (deployment.zoneId().environment().isProduction()) { // Add default and wildcard names for global endpoints - builders.add(endpointFactory.of(deployment.applicationId()).target(EndpointId.defaultId())); - builders.add(endpointFactory.of(deployment.applicationId()).wildcard()); + builders.add(Endpoint.of(deployment.applicationId()).target(EndpointId.defaultId())); + builders.add(Endpoint.of(deployment.applicationId()).wildcard()); // Add default and wildcard names for each region targeted by application endpoints List<DeploymentId> deploymentTargets = deploymentSpec.endpoints().stream() @@ -221,14 +218,14 @@ public class RoutingController { .toList(); TenantAndApplicationId application = TenantAndApplicationId.from(deployment.applicationId()); for (var targetDeployment : deploymentTargets) { - builders.add(endpointFactory.of(application).targetApplication(EndpointId.defaultId(), targetDeployment)); - builders.add(endpointFactory.of(application).wildcardApplication(targetDeployment)); + builders.add(Endpoint.of(application).targetApplication(EndpointId.defaultId(), targetDeployment)); + builders.add(Endpoint.of(application).wildcardApplication(targetDeployment)); } } // Add default and wildcard names for zone endpoints - builders.add(endpointFactory.of(deployment.applicationId()).target(ClusterSpec.Id.from("default"), deployment)); - builders.add(endpointFactory.of(deployment.applicationId()).wildcard(deployment)); + builders.add(Endpoint.of(deployment.applicationId()).target(ClusterSpec.Id.from("default"), deployment)); + builders.add(Endpoint.of(deployment.applicationId()).wildcard(deployment)); // Build all certificate names for (var builder : builders) { @@ -399,11 +396,11 @@ public class RoutingController { throw new IllegalArgumentException("Invalid routing methods for " + routingId + ": Exceeded maximum " + "direct methods"); } - endpoints.add(endpointFactory.of(routingId.instance()) - .target(routingId.endpointId(), cluster, deployments) - .on(Port.fromRoutingMethod(method)) - .routingMethod(method) - .in(controller.system())); + endpoints.add(Endpoint.of(routingId.instance()) + .target(routingId.endpointId(), cluster, deployments) + .on(Port.fromRoutingMethod(method)) + .routingMethod(method) + .in(controller.system())); } return endpoints; } diff --git a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/application/Endpoint.java b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/application/Endpoint.java index 2fe234d6902..40168db9c1d 100644 --- a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/application/Endpoint.java +++ b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/application/Endpoint.java @@ -14,7 +14,6 @@ import com.yahoo.vespa.hosted.controller.api.identifiers.DeploymentId; import com.yahoo.vespa.hosted.controller.api.integration.zone.ZoneRegistry; import java.net.URI; -import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Objects; @@ -167,8 +166,8 @@ public class Endpoint { } private static URI createUrl(String name, TenantAndApplicationId application, Optional<InstanceName> instance, - List<Target> targets, Scope scope, SystemName system, Port port, boolean legacy, - boolean includeRegionIfApplicationEndpoint) { + List<Target> targets, Scope scope, SystemName system, Port port, boolean legacy) { + String separator = "."; String portPart = port.isDefault() ? "" : ":" + port.port; return URI.create("https://" + @@ -179,7 +178,7 @@ public class Endpoint { separator + sanitize(application.tenant().value()) + "." + - scopePart(scope, targets, system, legacy, includeRegionIfApplicationEndpoint) + + scopePart(scope, targets, system, legacy) + dnsSuffix(system, legacy) + portPart + "/"); @@ -194,11 +193,11 @@ public class Endpoint { return name + separator; } - private static String scopePart(Scope scope, List<Target> targets, SystemName system, boolean legacy, boolean includeRegionIfApplicationEndpoint) { + private static String scopePart(Scope scope, List<Target> targets, SystemName system, boolean legacy) { String scopeSymbol = scopeSymbol(scope, system); Set<ZoneId> zones = targets.stream().map(target -> target.deployment.zoneId()).collect(toSet()); if (scope == Scope.global) return scopeSymbol; - if (scope == Scope.application && ! includeRegionIfApplicationEndpoint) return scopeSymbol; + if (scope == Scope.application) return scopeSymbol; ZoneId zone = targets.get(0).deployment().zoneId(); String region = zone.region().value(); @@ -424,34 +423,14 @@ public class Endpoint { } - public static class EndpointFactory { - - private final Function<ZoneId, CloudName> clouds; - - public EndpointFactory(Function<ZoneId, CloudName> clouds) { - this.clouds = clouds; - } - - public EndpointFactory(ZoneRegistry zones) { - this(zone -> findCloud(zone, zones)); - } - - /** Build an endpoint for given instance */ - public EndpointBuilder of(ApplicationId instance) { - return new EndpointBuilder(TenantAndApplicationId.from(instance), Optional.of(instance.instance()), clouds); - } - - /** Build an endpoint for given application */ - public EndpointBuilder of(TenantAndApplicationId application) { - return new EndpointBuilder(application, Optional.empty(), clouds); - } - - private static CloudName findCloud(ZoneId zone, ZoneRegistry zones) { - return zones.zones().all().get(zone) - .orElseThrow(() -> new IllegalArgumentException("unknown zone '" + zone + "'")) - .getCloudName(); - } + /** Build an endpoint for given instance */ + public static EndpointBuilder of(ApplicationId instance) { + return new EndpointBuilder(TenantAndApplicationId.from(instance), Optional.of(instance.instance())); + } + /** Build an endpoint for given application */ + public static EndpointBuilder of(TenantAndApplicationId application) { + return new EndpointBuilder(application, Optional.empty()); } /** A target of an endpoint */ @@ -494,8 +473,6 @@ public class Endpoint { private final TenantAndApplicationId application; private final Optional<InstanceName> instance; - private final Function<ZoneId, CloudName> cloudFinder; - private final Set<CloudName> clouds = new HashSet<>(); private Scope scope; private List<Target> targets; private ClusterSpec.Id cluster; @@ -505,10 +482,9 @@ public class Endpoint { private boolean legacy = false; private boolean certificateName = false; - private EndpointBuilder(TenantAndApplicationId application, Optional<InstanceName> instance, Function<ZoneId, CloudName> cloudFinder) { + private EndpointBuilder(TenantAndApplicationId application, Optional<InstanceName> instance) { this.application = Objects.requireNonNull(application); this.instance = Objects.requireNonNull(instance); - this.cloudFinder = Objects.requireNonNull(cloudFinder); } /** Sets the deployment target for this */ @@ -516,7 +492,6 @@ public class Endpoint { this.cluster = cluster; this.scope = requireUnset(Scope.zone); this.targets = List.of(new Target(deployment)); - this.clouds.add(cloudFinder.apply(deployment.zoneId())); return this; } @@ -526,7 +501,6 @@ public class Endpoint { this.cluster = cluster; this.targets = deployments.stream().map(Target::new).toList(); this.scope = requireUnset(Scope.global); - for (DeploymentId deployment : deployments) this.clouds.add(cloudFinder.apply(deployment.zoneId())); return this; } @@ -563,7 +537,6 @@ public class Endpoint { .map(kv -> new Target(kv.getKey(), kv.getValue())) .toList(); this.scope = Scope.application; - for (DeploymentId deploymentId : deployments.keySet()) this.clouds.add(cloudFinder.apply(deploymentId.zoneId())); return this; } @@ -572,7 +545,6 @@ public class Endpoint { this.cluster = cluster; this.scope = requireUnset(Scope.weighted); this.targets = List.of(new Target(new DeploymentId(application.instance(instance.get()), effectiveZone(zone)))); - this.clouds.add(cloudFinder.apply(zone)); return this; } @@ -608,7 +580,6 @@ public class Endpoint { if (routingMethod.isDirect() && !port.isDefault()) { throw new IllegalArgumentException("Routing method " + routingMethod + " can only use default port"); } - boolean includeRegionIfApplicationEndpoint = ! Set.of(CloudName.AWS, CloudName.GCP).containsAll(clouds); URI url = createUrl(endpointOrClusterAsString(endpointId, cluster), Objects.requireNonNull(application, "application must be non-null"), Objects.requireNonNull(instance, "instance must be non-null"), @@ -616,8 +587,7 @@ public class Endpoint { Objects.requireNonNull(scope, "scope must be non-null"), Objects.requireNonNull(system, "system must be non-null"), Objects.requireNonNull(port, "port must be non-null"), - legacy, - includeRegionIfApplicationEndpoint); + legacy); return new Endpoint(application, instance, endpointId, diff --git a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/routing/RoutingPolicy.java b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/routing/RoutingPolicy.java index 269ad0a65fd..6ae729a3c02 100644 --- a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/routing/RoutingPolicy.java +++ b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/routing/RoutingPolicy.java @@ -9,7 +9,6 @@ import com.yahoo.text.Text; import com.yahoo.vespa.hosted.controller.api.identifiers.DeploymentId; import com.yahoo.vespa.hosted.controller.api.integration.zone.ZoneRegistry; import com.yahoo.vespa.hosted.controller.application.Endpoint; -import com.yahoo.vespa.hosted.controller.application.Endpoint.EndpointFactory; import com.yahoo.vespa.hosted.controller.application.Endpoint.Port; import com.yahoo.vespa.hosted.controller.application.EndpointId; @@ -127,9 +126,9 @@ public record RoutingPolicy(RoutingPolicyId id, } private Endpoint.EndpointBuilder endpoint(RoutingMethod routingMethod, ZoneRegistry zones) { - return new EndpointFactory(zones).of(id.owner()) - .on(Port.fromRoutingMethod(routingMethod)) - .routingMethod(routingMethod); + return Endpoint.of(id.owner()) + .on(Port.fromRoutingMethod(routingMethod)) + .routingMethod(routingMethod); } /** The status of a routing policy */ diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/ControllerTest.java b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/ControllerTest.java index 2cc3cff455c..aaae5d9a1cb 100644 --- a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/ControllerTest.java +++ b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/ControllerTest.java @@ -666,9 +666,9 @@ public class ControllerTest { // Expected container endpoints are passed to each deployment Map<DeploymentId, Map<String, Integer>> deploymentEndpoints = Map.of( new DeploymentId(beta, east3), Map.of(), - new DeploymentId(main, east3), Map.of("e.app1.tenant1.us-east-3-r.vespa.oath.cloud", 3), - new DeploymentId(beta, west1), Map.of("d.app1.tenant1.us-west-1-r.vespa.oath.cloud", 3), - new DeploymentId(main, west1), Map.of("d.app1.tenant1.us-west-1-r.vespa.oath.cloud", 7), + new DeploymentId(main, east3), Map.of("e.app1.tenant1.r.vespa.oath.cloud", 3), + new DeploymentId(beta, west1), Map.of("d.app1.tenant1.r.vespa.oath.cloud", 3), + new DeploymentId(main, west1), Map.of("d.app1.tenant1.r.vespa.oath.cloud", 7), new DeploymentId(beta, east1a), Map.of("a.app1.tenant1.r.vespa.oath.cloud", 2, "b.app1.tenant1.r.vespa.oath.cloud", 1), new DeploymentId(main, east1a), Map.of("a.app1.tenant1.r.vespa.oath.cloud", 8, @@ -722,10 +722,10 @@ public class ControllerTest { RecordName.from("c.app1.tenant1.r.vespa.oath.cloud"), RecordData.from("weighted/lb-0--tenant1.app1.beta--prod.aws-us-east-1b/dns-zone-1/prod.aws-us-east-1b/4")), new Record(Record.Type.CNAME, - RecordName.from("d.app1.tenant1.us-west-1-r.vespa.oath.cloud"), + RecordName.from("d.app1.tenant1.r.vespa.oath.cloud"), RecordData.from("vip.prod.us-west-1.")), new Record(Record.Type.CNAME, - RecordName.from("e.app1.tenant1.us-east-3-r.vespa.oath.cloud"), + RecordName.from("e.app1.tenant1.r.vespa.oath.cloud"), RecordData.from("vip.prod.us-east-3.")))), new TreeSet<>(records)); List<String> endpointDnsNames = tester.controller().routing().declaredEndpointsOf(context.application()) @@ -735,8 +735,8 @@ public class ControllerTest { assertEquals(List.of("a.app1.tenant1.r.vespa.oath.cloud", "b.app1.tenant1.r.vespa.oath.cloud", "c.app1.tenant1.r.vespa.oath.cloud", - "d.app1.tenant1.us-west-1-r.vespa.oath.cloud", - "e.app1.tenant1.us-east-3-r.vespa.oath.cloud"), + "d.app1.tenant1.r.vespa.oath.cloud", + "e.app1.tenant1.r.vespa.oath.cloud"), endpointDnsNames); } diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/application/EndpointTest.java b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/application/EndpointTest.java index f56b63dd2d9..28ed8085d56 100644 --- a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/application/EndpointTest.java +++ b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/application/EndpointTest.java @@ -8,7 +8,6 @@ import com.yahoo.config.provision.SystemName; import com.yahoo.config.provision.zone.RoutingMethod; import com.yahoo.config.provision.zone.ZoneId; import com.yahoo.vespa.hosted.controller.api.identifiers.DeploymentId; -import com.yahoo.vespa.hosted.controller.application.Endpoint.EndpointFactory; import com.yahoo.vespa.hosted.controller.application.Endpoint.Port; import org.junit.jupiter.api.Test; @@ -26,8 +25,6 @@ public class EndpointTest { private static final ApplicationId instance2 = ApplicationId.from("t2", "a2", "i2"); private static final TenantAndApplicationId app1 = TenantAndApplicationId.from(instance1); private static final TenantAndApplicationId app2 = TenantAndApplicationId.from(instance2); - private static final EndpointFactory defaultFactory = new EndpointFactory(__ -> CloudName.DEFAULT); - private static final EndpointFactory otherFactory = new EndpointFactory(__ -> CloudName.AWS); @Test void global_endpoints() { @@ -39,38 +36,38 @@ public class EndpointTest { Map<String, Endpoint> tests = Map.of( // Main endpoint with direct routing and default TLS port "https://a1.t1.global.vespa.oath.cloud/", - defaultFactory.of(instance1).target(endpointId, cluster, List.of(deployment1)).on(Port.tls()).routingMethod(RoutingMethod.exclusive).in(SystemName.main), + Endpoint.of(instance1).target(endpointId, cluster, List.of(deployment1)).on(Port.tls()).routingMethod(RoutingMethod.exclusive).in(SystemName.main), // Main endpoint with custom rotation name "https://r1.a1.t1.global.vespa.oath.cloud/", - defaultFactory.of(instance1).target(EndpointId.of("r1"), cluster, List.of(deployment1)).on(Port.tls()).routingMethod(RoutingMethod.exclusive).in(SystemName.main), + Endpoint.of(instance1).target(EndpointId.of("r1"), cluster, List.of(deployment1)).on(Port.tls()).routingMethod(RoutingMethod.exclusive).in(SystemName.main), // Main endpoint for custom instance in default rotation "https://i2.a2.t2.global.vespa.oath.cloud/", - defaultFactory.of(instance2).target(endpointId, cluster, List.of(deployment2)).on(Port.tls()).routingMethod(RoutingMethod.exclusive).in(SystemName.main), + Endpoint.of(instance2).target(endpointId, cluster, List.of(deployment2)).on(Port.tls()).routingMethod(RoutingMethod.exclusive).in(SystemName.main), // Main endpoint for custom instance with custom rotation name "https://r2.i2.a2.t2.global.vespa.oath.cloud/", - defaultFactory.of(instance2).target(EndpointId.of("r2"), cluster, List.of(deployment2)).on(Port.tls()).routingMethod(RoutingMethod.exclusive).in(SystemName.main), + Endpoint.of(instance2).target(EndpointId.of("r2"), cluster, List.of(deployment2)).on(Port.tls()).routingMethod(RoutingMethod.exclusive).in(SystemName.main), // Main endpoint in public system "https://a1.t1.g.vespa-app.cloud/", - defaultFactory.of(instance1).target(endpointId, cluster, List.of(deployment1)).on(Port.tls()).routingMethod(RoutingMethod.exclusive).in(SystemName.Public) + Endpoint.of(instance1).target(endpointId, cluster, List.of(deployment1)).on(Port.tls()).routingMethod(RoutingMethod.exclusive).in(SystemName.Public) ); tests.forEach((expected, endpoint) -> assertEquals(expected, endpoint.url().toString())); Map<String, Endpoint> tests2 = Map.of( // Default endpoint in public system "https://a1.t1.g.vespa-app.cloud/", - defaultFactory.of(instance1).target(endpointId, cluster, List.of(deployment1)).on(Port.tls()).routingMethod(RoutingMethod.exclusive).in(SystemName.Public), + Endpoint.of(instance1).target(endpointId, cluster, List.of(deployment1)).on(Port.tls()).routingMethod(RoutingMethod.exclusive).in(SystemName.Public), // Default endpoint in public CD system "https://a1.t1.g.cd.vespa-app.cloud/", - defaultFactory.of(instance1).target(endpointId, cluster, List.of(deployment1)).on(Port.tls()).routingMethod(RoutingMethod.exclusive).in(SystemName.PublicCd), + Endpoint.of(instance1).target(endpointId, cluster, List.of(deployment1)).on(Port.tls()).routingMethod(RoutingMethod.exclusive).in(SystemName.PublicCd), // Custom instance in public system "https://i2.a2.t2.g.vespa-app.cloud/", - defaultFactory.of(instance2).target(endpointId, cluster, List.of(deployment2)).on(Port.tls()).routingMethod(RoutingMethod.exclusive).in(SystemName.Public) + Endpoint.of(instance2).target(endpointId, cluster, List.of(deployment2)).on(Port.tls()).routingMethod(RoutingMethod.exclusive).in(SystemName.Public) ); tests2.forEach((expected, endpoint) -> assertEquals(expected, endpoint.url().toString())); } @@ -85,34 +82,34 @@ public class EndpointTest { Map<String, Endpoint> tests = Map.of( // Main endpoint with direct routing and default TLS port "https://a1.t1.global.vespa.oath.cloud/", - defaultFactory.of(instance1).target(endpointId, cluster, List.of(deployment1)).on(Port.tls()).routingMethod(RoutingMethod.exclusive).in(SystemName.main), + Endpoint.of(instance1).target(endpointId, cluster, List.of(deployment1)).on(Port.tls()).routingMethod(RoutingMethod.exclusive).in(SystemName.main), // Main endpoint with custom rotation name "https://r1.a1.t1.global.vespa.oath.cloud/", - defaultFactory.of(instance1).target(EndpointId.of("r1"), cluster, List.of(deployment1)).on(Port.tls()).routingMethod(RoutingMethod.exclusive).in(SystemName.main), + Endpoint.of(instance1).target(EndpointId.of("r1"), cluster, List.of(deployment1)).on(Port.tls()).routingMethod(RoutingMethod.exclusive).in(SystemName.main), // Main endpoint for custom instance in default rotation "https://i2.a2.t2.global.vespa.oath.cloud/", - defaultFactory.of(instance2).target(endpointId, cluster, List.of(deployment2)).on(Port.tls()).routingMethod(RoutingMethod.exclusive).in(SystemName.main), + Endpoint.of(instance2).target(endpointId, cluster, List.of(deployment2)).on(Port.tls()).routingMethod(RoutingMethod.exclusive).in(SystemName.main), // Main endpoint for custom instance with custom rotation name "https://r2.i2.a2.t2.global.vespa.oath.cloud/", - defaultFactory.of(instance2).target(EndpointId.of("r2"), cluster, List.of(deployment2)).on(Port.tls()).routingMethod(RoutingMethod.exclusive).in(SystemName.main), + Endpoint.of(instance2).target(EndpointId.of("r2"), cluster, List.of(deployment2)).on(Port.tls()).routingMethod(RoutingMethod.exclusive).in(SystemName.main), // Main endpoint in public system "https://a1.t1.g.vespa-app.cloud/", - defaultFactory.of(instance1).target(endpointId, cluster, List.of(deployment1)).on(Port.tls()).routingMethod(RoutingMethod.exclusive).in(SystemName.Public) + Endpoint.of(instance1).target(endpointId, cluster, List.of(deployment1)).on(Port.tls()).routingMethod(RoutingMethod.exclusive).in(SystemName.Public) ); tests.forEach((expected, endpoint) -> assertEquals(expected, endpoint.url().toString())); Map<String, Endpoint> tests2 = Map.of( // Custom endpoint and instance in public CD system) "https://foo.i2.a2.t2.g.cd.vespa-app.cloud/", - defaultFactory.of(instance2).target(EndpointId.of("foo"), cluster, List.of(deployment2)).on(Port.tls()).routingMethod(RoutingMethod.exclusive).in(SystemName.PublicCd), + Endpoint.of(instance2).target(EndpointId.of("foo"), cluster, List.of(deployment2)).on(Port.tls()).routingMethod(RoutingMethod.exclusive).in(SystemName.PublicCd), // Custom endpoint and instance in public system "https://foo.i2.a2.t2.g.vespa-app.cloud/", - defaultFactory.of(instance2).target(EndpointId.of("foo"), cluster, List.of(deployment2)).on(Port.tls()).routingMethod(RoutingMethod.exclusive).in(SystemName.Public) + Endpoint.of(instance2).target(EndpointId.of("foo"), cluster, List.of(deployment2)).on(Port.tls()).routingMethod(RoutingMethod.exclusive).in(SystemName.Public) ); tests2.forEach((expected, endpoint) -> assertEquals(expected, endpoint.url().toString())); } @@ -127,50 +124,50 @@ public class EndpointTest { Map<String, Endpoint> tests = Map.of( // Prod endpoint in main "https://a1.t1.us-north-1.vespa.oath.cloud/", - defaultFactory.of(instance1).target(cluster, prodZone).on(Port.tls()).in(SystemName.main), + Endpoint.of(instance1).target(cluster, prodZone).on(Port.tls()).in(SystemName.main), // Prod endpoint in CD "https://cd.a1.t1.us-north-1.vespa.oath.cloud/", - defaultFactory.of(instance1).target(cluster, prodZone).on(Port.tls()).in(SystemName.cd), + Endpoint.of(instance1).target(cluster, prodZone).on(Port.tls()).in(SystemName.cd), // Test endpoint in main "https://a1.t1.us-north-2.test.vespa.oath.cloud/", - defaultFactory.of(instance1).target(cluster, testZone).on(Port.tls()).in(SystemName.main), + Endpoint.of(instance1).target(cluster, testZone).on(Port.tls()).in(SystemName.main), // Non-default cluster in main "https://c1.a1.t1.us-north-1.vespa.oath.cloud/", - defaultFactory.of(instance1).target(ClusterSpec.Id.from("c1"), prodZone).on(Port.tls()).in(SystemName.main), + Endpoint.of(instance1).target(ClusterSpec.Id.from("c1"), prodZone).on(Port.tls()).in(SystemName.main), // Non-default instance in main "https://i2.a2.t2.us-north-1.vespa.oath.cloud/", - defaultFactory.of(instance2).target(cluster, prodZone2).on(Port.tls()).in(SystemName.main), + Endpoint.of(instance2).target(cluster, prodZone2).on(Port.tls()).in(SystemName.main), // Non-default cluster in public "https://c1.a1.t1.us-north-1.z.vespa-app.cloud/", - defaultFactory.of(instance1).target(ClusterSpec.Id.from("c1"), prodZone).on(Port.tls()).routingMethod(RoutingMethod.exclusive).in(SystemName.Public), + Endpoint.of(instance1).target(ClusterSpec.Id.from("c1"), prodZone).on(Port.tls()).routingMethod(RoutingMethod.exclusive).in(SystemName.Public), // Non-default cluster and instance in public "https://c2.i2.a2.t2.us-north-1.z.vespa-app.cloud/", - defaultFactory.of(instance2).target(ClusterSpec.Id.from("c2"), prodZone2).on(Port.tls()).routingMethod(RoutingMethod.exclusive).in(SystemName.Public) + Endpoint.of(instance2).target(ClusterSpec.Id.from("c2"), prodZone2).on(Port.tls()).routingMethod(RoutingMethod.exclusive).in(SystemName.Public) ); tests.forEach((expected, endpoint) -> assertEquals(expected, endpoint.url().toString())); Map<String, Endpoint> tests2 = Map.of( // Non-default cluster and instance in public CD (legacy) "https://c2.i2.a2.t2.us-north-1.z.cd.vespa-app.cloud/", - defaultFactory.of(instance2).target(ClusterSpec.Id.from("c2"), prodZone2).on(Port.tls()).routingMethod(RoutingMethod.exclusive).in(SystemName.PublicCd), + Endpoint.of(instance2).target(ClusterSpec.Id.from("c2"), prodZone2).on(Port.tls()).routingMethod(RoutingMethod.exclusive).in(SystemName.PublicCd), // Custom cluster name in public "https://c1.a1.t1.us-north-1.z.vespa-app.cloud/", - defaultFactory.of(instance1).target(ClusterSpec.Id.from("c1"), prodZone).on(Port.tls()).routingMethod(RoutingMethod.exclusive).in(SystemName.Public), + Endpoint.of(instance1).target(ClusterSpec.Id.from("c1"), prodZone).on(Port.tls()).routingMethod(RoutingMethod.exclusive).in(SystemName.Public), // Default cluster name in non-production zone in public "https://a1.t1.us-north-2.test.z.vespa-app.cloud/", - defaultFactory.of(instance1).target(ClusterSpec.Id.from("default"), testZone).on(Port.tls()).routingMethod(RoutingMethod.exclusive).in(SystemName.Public), + Endpoint.of(instance1).target(ClusterSpec.Id.from("default"), testZone).on(Port.tls()).routingMethod(RoutingMethod.exclusive).in(SystemName.Public), // Default cluster name in public CD "https://a1.t1.us-north-1.z.cd.vespa-app.cloud/", - defaultFactory.of(instance1).target(ClusterSpec.Id.from("default"), prodZone).on(Port.tls()).routingMethod(RoutingMethod.exclusive).in(SystemName.PublicCd) + Endpoint.of(instance1).target(ClusterSpec.Id.from("default"), prodZone).on(Port.tls()).routingMethod(RoutingMethod.exclusive).in(SystemName.PublicCd) ); tests2.forEach((expected, endpoint) -> assertEquals(expected, endpoint.url().toString())); } @@ -184,7 +181,7 @@ public class EndpointTest { var tests = Map.of( // Default rotation "https://a1.t1.g.vespa-app.cloud/", - defaultFactory.of(instance1) + Endpoint.of(instance1) .target(EndpointId.defaultId()) .certificateName() .routingMethod(RoutingMethod.exclusive) @@ -193,7 +190,7 @@ public class EndpointTest { // Wildcard to match other rotations "https://*.a1.t1.g.vespa-app.cloud/", - defaultFactory.of(instance1) + Endpoint.of(instance1) .wildcard() .certificateName() .routingMethod(RoutingMethod.exclusive) @@ -202,7 +199,7 @@ public class EndpointTest { // Default cluster in zone "https://a1.t1.us-north-1.z.vespa-app.cloud/", - defaultFactory.of(instance1) + Endpoint.of(instance1) .target(defaultCluster, prodZone) .certificateName() .routingMethod(RoutingMethod.exclusive) @@ -211,7 +208,7 @@ public class EndpointTest { // Default cluster in test zone "https://a1.t1.us-north-2.test.z.vespa-app.cloud/", - defaultFactory.of(instance1) + Endpoint.of(instance1) .target(defaultCluster, testZone) .certificateName() .routingMethod(RoutingMethod.exclusive) @@ -220,7 +217,7 @@ public class EndpointTest { // Wildcard to match other clusters in test zone "https://*.a1.t1.us-north-2.test.z.vespa-app.cloud/", - defaultFactory.of(instance1) + Endpoint.of(instance1) .wildcard(testZone) .certificateName() .routingMethod(RoutingMethod.exclusive) @@ -229,7 +226,7 @@ public class EndpointTest { // Wildcard to match other clusters in zone "https://*.a1.t1.us-north-1.z.vespa-app.cloud/", - defaultFactory.of(instance1) + Endpoint.of(instance1) .wildcard(prodZone) .certificateName() .routingMethod(RoutingMethod.exclusive) @@ -246,25 +243,25 @@ public class EndpointTest { var prodZone = ZoneId.from("prod", "us-north-2"); Map<String, Endpoint> tests = Map.of( "https://a1.t1.aws-us-north-1.w.vespa-app.cloud/", - defaultFactory.of(instance1) + Endpoint.of(instance1) .targetRegion(cluster, ZoneId.from("prod", "aws-us-north-1a")) .routingMethod(RoutingMethod.exclusive) .on(Port.tls()) .in(SystemName.Public), "https://a1.t1.gcp-us-south1.w.vespa-app.cloud/", - defaultFactory.of(instance1) + Endpoint.of(instance1) .targetRegion(cluster, ZoneId.from("prod", "gcp-us-south1-c")) .routingMethod(RoutingMethod.exclusive) .on(Port.tls()) .in(SystemName.Public), "https://a1.t1.us-north-2.w.vespa-app.cloud/", - defaultFactory.of(instance1) + Endpoint.of(instance1) .targetRegion(cluster, prodZone) .routingMethod(RoutingMethod.exclusive) .on(Port.tls()) .in(SystemName.Public), "https://c1.a1.t1.us-north-2.w.vespa-app.cloud/", - defaultFactory.of(instance1) + Endpoint.of(instance1) .targetRegion(ClusterSpec.Id.from("c1"), prodZone) .routingMethod(RoutingMethod.exclusive) .on(Port.tls()) @@ -284,28 +281,28 @@ public class EndpointTest { void application_endpoints() { Map<String, Endpoint> tests = Map.of( "https://weighted.a1.t1.r.vespa-app.cloud/", - otherFactory.of(app1) + Endpoint.of(app1) .targetApplication(EndpointId.of("weighted"), ClusterSpec.Id.from("qrs"), Map.of(new DeploymentId(app1.instance("i1"), ZoneId.from("prod", "us-west-1")), 1)) .routingMethod(RoutingMethod.exclusive) .on(Port.tls()) .in(SystemName.Public), - "https://weighted.a1.t1.us-west-1.r.cd.vespa-app.cloud/", - defaultFactory.of(app1) + "https://weighted.a1.t1.r.cd.vespa-app.cloud/", + Endpoint.of(app1) .targetApplication(EndpointId.of("weighted"), ClusterSpec.Id.from("qrs"), Map.of(new DeploymentId(app1.instance("i1"), ZoneId.from("prod", "us-west-1")), 1)) .routingMethod(RoutingMethod.exclusive) .on(Port.tls()) .in(SystemName.PublicCd), "https://a2.t2.r.vespa.oath.cloud/", - otherFactory.of(app2) + Endpoint.of(app2) .targetApplication(EndpointId.defaultId(), ClusterSpec.Id.from("qrs"), Map.of(new DeploymentId(app2.instance("i1"), ZoneId.from("prod", "us-east-3")), 1)) .routingMethod(RoutingMethod.exclusive) .on(Port.tls()) .in(SystemName.main), - "https://cd.a2.t2.us-east-3-r.vespa.oath.cloud/", - defaultFactory.of(app2) + "https://cd.a2.t2.r.vespa.oath.cloud/", + Endpoint.of(app2) .targetApplication(EndpointId.defaultId(), ClusterSpec.Id.from("qrs"), Map.of(new DeploymentId(app2.instance("i1"), ZoneId.from("prod", "us-east-3")), 1)) .routingMethod(RoutingMethod.exclusive) @@ -322,15 +319,15 @@ public class EndpointTest { var tests1 = Map.of( // With default cluster "a1.t1.us-north-1.prod", - defaultFactory.of(instance1).target(EndpointId.defaultId(), ClusterSpec.Id.from("default"), List.of(zone)).on(Port.tls()).in(SystemName.main), + Endpoint.of(instance1).target(EndpointId.defaultId(), ClusterSpec.Id.from("default"), List.of(zone)).on(Port.tls()).in(SystemName.main), // With non-default cluster "c1.a1.t1.us-north-1.prod", - defaultFactory.of(instance1).target(EndpointId.of("ignored1"), ClusterSpec.Id.from("c1"), List.of(zone)).on(Port.tls()).in(SystemName.main), + Endpoint.of(instance1).target(EndpointId.of("ignored1"), ClusterSpec.Id.from("c1"), List.of(zone)).on(Port.tls()).in(SystemName.main), // With application endpoint "c2.a1.t1.us-north-1.prod", - defaultFactory.of(app1).targetApplication(EndpointId.defaultId(), ClusterSpec.Id.from("c2"), Map.of(new DeploymentId(app1.instance("i1"), zone.zoneId()), 1)) + Endpoint.of(app1).targetApplication(EndpointId.defaultId(), ClusterSpec.Id.from("c2"), Map.of(new DeploymentId(app1.instance("i1"), zone.zoneId()), 1)) .routingMethod(RoutingMethod.sharedLayer4) .on(Port.tls()) .in(SystemName.main) @@ -338,11 +335,11 @@ public class EndpointTest { var tests2 = Map.of( // With non-default instance and default cluster "i2.a2.t2.us-north-1.prod", - defaultFactory.of(instance2).target(EndpointId.defaultId(), ClusterSpec.Id.from("default"), List.of(zone2)).on(Port.tls()).in(SystemName.main), + Endpoint.of(instance2).target(EndpointId.defaultId(), ClusterSpec.Id.from("default"), List.of(zone2)).on(Port.tls()).in(SystemName.main), // With non-default instance and cluster "c2.i2.a2.t2.us-north-1.prod", - defaultFactory.of(instance2).target(EndpointId.of("ignored2"), ClusterSpec.Id.from("c2"), List.of(zone2)).on(Port.tls()).in(SystemName.main) + Endpoint.of(instance2).target(EndpointId.of("ignored2"), ClusterSpec.Id.from("c2"), List.of(zone2)).on(Port.tls()).in(SystemName.main) ); tests1.forEach((expected, endpoint) -> assertEquals(expected, endpoint.upstreamName(zone))); tests2.forEach((expected, endpoint) -> assertEquals(expected, endpoint.upstreamName(zone2))); diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/certificate/EndpointCertificatesTest.java b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/certificate/EndpointCertificatesTest.java index 6be6aa84319..30a9cabd403 100644 --- a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/certificate/EndpointCertificatesTest.java +++ b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/certificate/EndpointCertificatesTest.java @@ -270,8 +270,6 @@ public class EndpointCertificatesTest { "*.a1.t1.g.vespa-app.cloud", "a1.t1.r.vespa-app.cloud", "*.a1.t1.r.vespa-app.cloud", - "a1.t1.aws-us-east-1c.r.vespa-app.cloud", - "*.a1.t1.aws-us-east-1c.r.vespa-app.cloud", "a1.t1.aws-us-east-1c.z.vespa-app.cloud", "*.a1.t1.aws-us-east-1c.z.vespa-app.cloud", "a1.t1.us-east-1.test.z.vespa-app.cloud", diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/deployment/TestConfigSerializerTest.java b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/deployment/TestConfigSerializerTest.java index ba05cdf2fd5..831a79f24b8 100644 --- a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/deployment/TestConfigSerializerTest.java +++ b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/deployment/TestConfigSerializerTest.java @@ -11,7 +11,6 @@ import com.yahoo.slime.SlimeUtils; import com.yahoo.vespa.hosted.controller.api.identifiers.DeploymentId; import com.yahoo.vespa.hosted.controller.api.integration.deployment.RevisionId; import com.yahoo.vespa.hosted.controller.application.Endpoint; -import com.yahoo.vespa.hosted.controller.application.Endpoint.EndpointFactory; import com.yahoo.vespa.hosted.controller.application.EndpointId; import org.junit.jupiter.api.Test; @@ -40,12 +39,12 @@ public class TestConfigSerializerTest { Version.fromString("1.2.3"), RevisionId.forProduction(321), Instant.ofEpochMilli(222), - Map.of(zone, List.of(new EndpointFactory(__ -> CloudName.DEFAULT).of(ApplicationId.defaultId()) - .target(EndpointId.of("ai"), ClusterSpec.Id.from("qrs"), + Map.of(zone, List.of(Endpoint.of(ApplicationId.defaultId()) + .target(EndpointId.of("ai"), ClusterSpec.Id.from("qrs"), List.of(new DeploymentId(ApplicationId.defaultId(), ZoneId.defaultId()))) - .on(Endpoint.Port.tls()) - .in(SystemName.main))), + .on(Endpoint.Port.tls()) + .in(SystemName.main))), Map.of(zone, List.of("facts"))); byte[] expected = Files.readAllBytes(Paths.get("src/test/resources/testConfig.json")); assertEquals(new String(SlimeUtils.toJsonBytes(SlimeUtils.jsonToSlime(expected))), diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/application/responses/deployment.json b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/application/responses/deployment.json index 37bd69d5863..3a274349835 100644 --- a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/application/responses/deployment.json +++ b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/application/responses/deployment.json @@ -24,7 +24,7 @@ { "cluster": "foo", "tls": true, - "url": "https://a0.application1.tenant1.us-central-1-r.vespa.oath.cloud/", + "url": "https://a0.application1.tenant1.r.vespa.oath.cloud/", "scope": "application", "routingMethod": "sharedLayer4", "legacy": false diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/application/responses/instance1-recursive.json b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/application/responses/instance1-recursive.json index d78ab67dcc5..310e948478b 100644 --- a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/application/responses/instance1-recursive.json +++ b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/application/responses/instance1-recursive.json @@ -111,7 +111,7 @@ { "cluster": "foo", "tls": true, - "url": "https://a0.application1.tenant1.us-central-1-r.vespa.oath.cloud/", + "url": "https://a0.application1.tenant1.r.vespa.oath.cloud/", "scope": "application", "routingMethod": "sharedLayer4", "legacy": false diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/application/responses/recursive-root.json b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/application/responses/recursive-root.json index 8d76d54458d..6bb48df75d9 100644 --- a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/application/responses/recursive-root.json +++ b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/application/responses/recursive-root.json @@ -118,7 +118,7 @@ { "cluster": "foo", "tls": true, - "url": "https://a0.application1.tenant1.us-central-1-r.vespa.oath.cloud/", + "url": "https://a0.application1.tenant1.r.vespa.oath.cloud/", "scope": "application", "routingMethod": "sharedLayer4", "legacy": false diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/application/responses/tenant1-recursive.json b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/application/responses/tenant1-recursive.json index b9bf714d362..167efce9b9e 100644 --- a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/application/responses/tenant1-recursive.json +++ b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/application/responses/tenant1-recursive.json @@ -117,7 +117,7 @@ { "cluster": "foo", "tls": true, - "url": "https://a0.application1.tenant1.us-central-1-r.vespa.oath.cloud/", + "url": "https://a0.application1.tenant1.r.vespa.oath.cloud/", "scope": "application", "routingMethod": "sharedLayer4", "legacy": false |