summaryrefslogtreecommitdiffstats
path: root/controller-server
diff options
context:
space:
mode:
authorMartin Polden <mpolden@mpolden.no>2021-05-06 09:38:40 +0200
committerMartin Polden <mpolden@mpolden.no>2021-05-07 16:09:33 +0200
commit7b3caf1a2f1dad3e102fdca7fd93c6b825027240 (patch)
treec657130450c869d0dff3fec2c7dafd13daf2989a /controller-server
parent66da407bb26a9a09ffb2142eb82e4eef27ff0698 (diff)
Support building vespa-app.cloud endpoints
Diffstat (limited to 'controller-server')
-rw-r--r--controller-server/src/main/java/com/yahoo/vespa/hosted/controller/application/Endpoint.java23
-rw-r--r--controller-server/src/test/java/com/yahoo/vespa/hosted/controller/application/EndpointTest.java49
2 files changed, 66 insertions, 6 deletions
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 cc1a0a455c4..3f079a5fb9b 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
@@ -28,6 +28,10 @@ public class Endpoint {
private static final String OATH_DNS_SUFFIX = ".vespa.oath.cloud";
private static final String PUBLIC_DNS_SUFFIX = ".public.vespa.oath.cloud";
private static final String PUBLIC_CD_DNS_SUFFIX = ".public-cd.vespa.oath.cloud";
+ // TODO(mpolden): New domain is considered "legacy" for the time being, until it's ready for use. Once it's ready
+ // we'll make the vespa.oath.cloud variant legacy and this non-legacy.
+ private static final String PUBLIC_DNS_LEGACY_SUFFIX = ".vespa-app.cloud";
+ private static final String PUBLIC_CD_LEGACY_DNS_SUFFIX = ".cd.vespa-app.cloud";
private final EndpointId id;
private final ClusterSpec.Id cluster;
@@ -173,13 +177,13 @@ public class Endpoint {
String portPart = port.isDefault() ? "" : ":" + port.port;
return URI.create(scheme + "://" +
sanitize(namePart(name, separator)) +
- systemPart(system, separator) +
+ systemPart(system, separator, legacy) +
sanitize(instancePart(application, separator)) +
sanitize(application.application().value()) +
separator +
sanitize(application.tenant().value()) +
"." +
- scopePart(scope, zones, legacy) +
+ scopePart(scope, zones, legacy, system) +
dnsSuffix(system, legacy) +
portPart +
"/");
@@ -201,7 +205,15 @@ public class Endpoint {
return name + separator;
}
- private static String scopePart(Scope scope, List<ZoneId> zones, boolean legacy) {
+ private static String scopePart(Scope scope, List<ZoneId> zones, boolean legacy, SystemName system) {
+ if (system.isPublic() && legacy) {
+ if (scope == Scope.global) return "g";
+ var zone = zones.get(0);
+ var region = zone.region().value();
+ char scopeSymbol = scope == Scope.region ? 'r' : 'z';
+ String environment = zone.environment().isProduction() ? "" : "." + zone.environment().value();
+ return region + environment + "." + scopeSymbol;
+ }
if (scope == Scope.global) return "global";
var zone = zones.get(0);
var region = zone.region().value();
@@ -215,8 +227,9 @@ public class Endpoint {
return application.instance().value() + separator;
}
- private static String systemPart(SystemName system, String separator) {
+ private static String systemPart(SystemName system, String separator, boolean legacy) {
if (!system.isCd()) return "";
+ if (system.isPublic() && legacy) return "";
return system.value() + separator;
}
@@ -227,8 +240,10 @@ public class Endpoint {
if (legacy) return YAHOO_DNS_SUFFIX;
return OATH_DNS_SUFFIX;
case Public:
+ if (legacy) return PUBLIC_DNS_LEGACY_SUFFIX;
return PUBLIC_DNS_SUFFIX;
case PublicCd:
+ if (legacy) return PUBLIC_CD_LEGACY_DNS_SUFFIX;
return PUBLIC_CD_DNS_SUFFIX;
default: throw new IllegalArgumentException("No DNS suffix declared for system " + system);
}
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 2d81d7304a1..468c92d3539 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
@@ -69,6 +69,21 @@ public class EndpointTest {
Endpoint.of(app1).target(endpointId).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 using new domain
+ "https://a1.t1.g.vespa-app.cloud/",
+ Endpoint.of(app1).target(endpointId).on(Port.tls()).routingMethod(RoutingMethod.exclusive).legacy().in(SystemName.Public),
+
+ // Default endpoint in public CD system using new domain
+ "https://a1.t1.g.cd.vespa-app.cloud/",
+ Endpoint.of(app1).target(endpointId).on(Port.tls()).routingMethod(RoutingMethod.exclusive).legacy().in(SystemName.PublicCd),
+
+ // Custom instance in public system, using new domain
+ "https://i2.a2.t2.g.vespa-app.cloud/",
+ Endpoint.of(app2).target(endpointId).on(Port.tls()).routingMethod(RoutingMethod.exclusive).legacy().in(SystemName.Public)
+ );
+ tests2.forEach((expected, endpoint) -> assertEquals(expected, endpoint.url().toString()));
}
@Test
@@ -117,6 +132,13 @@ public class EndpointTest {
Endpoint.of(app1).target(endpointId).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 system, using new domain
+ "https://foo.i2.a2.t2.g.vespa-app.cloud/",
+ Endpoint.of(app2).target(EndpointId.of("foo")).on(Port.tls()).routingMethod(RoutingMethod.exclusive).legacy().in(SystemName.Public)
+ );
+ tests2.forEach((expected, endpoint) -> assertEquals(expected, endpoint.url().toString()));
}
@Test
@@ -167,6 +189,21 @@ public class EndpointTest {
Endpoint.of(app1).target(cluster, prodZone).on(Port.tls()).routingMethod(RoutingMethod.sharedLayer4).in(SystemName.main)
);
tests.forEach((expected, endpoint) -> assertEquals(expected, endpoint.url().toString()));
+
+ Map<String, Endpoint> tests2 = Map.of(
+ // Custom cluster name in public, using new domain
+ "https://c1.a1.t1.us-north-1.z.vespa-app.cloud/",
+ Endpoint.of(app1).target(ClusterSpec.Id.from("c1"), prodZone).on(Port.tls()).routingMethod(RoutingMethod.exclusive).legacy().in(SystemName.Public),
+
+ // Default cluster name in non-production zone in public, using new domain
+ "https://a1.t1.us-north-2.test.z.vespa-app.cloud/",
+ Endpoint.of(app1).target(ClusterSpec.Id.from("default"), testZone).on(Port.tls()).routingMethod(RoutingMethod.exclusive).legacy().in(SystemName.Public),
+
+ // Default cluster name in public CD, using new domain
+ "https://a1.t1.us-north-1.z.cd.vespa-app.cloud/",
+ Endpoint.of(app1).target(ClusterSpec.Id.from("default"), prodZone).on(Port.tls()).routingMethod(RoutingMethod.exclusive).legacy().in(SystemName.PublicCd)
+ );
+ tests2.forEach((expected, endpoint) -> assertEquals(expected, endpoint.url().toString()));
}
@Test
@@ -229,8 +266,9 @@ public class EndpointTest {
}
@Test
- public void weighted_endpoints() {
+ public void region_endpoints() {
var cluster = ClusterSpec.Id.from("default");
+ var prodZone = ZoneId.from("prod", "us-north-2");
Map<String, Endpoint> tests = Map.of(
"https://a1.t1.us-north-1-w.public.vespa.oath.cloud/",
Endpoint.of(app1)
@@ -240,7 +278,7 @@ public class EndpointTest {
.in(SystemName.Public),
"https://a1.t1.us-north-2-w.public.vespa.oath.cloud/",
Endpoint.of(app1)
- .targetRegion(cluster, ZoneId.from("prod", "us-north-2"))
+ .targetRegion(cluster, prodZone)
.routingMethod(RoutingMethod.exclusive)
.on(Port.tls())
.in(SystemName.Public),
@@ -249,6 +287,13 @@ public class EndpointTest {
.targetRegion(cluster, ZoneId.from("test", "us-north-2"))
.routingMethod(RoutingMethod.exclusive)
.on(Port.tls())
+ .in(SystemName.Public),
+ "https://c1.a1.t1.us-north-2.r.vespa-app.cloud/",
+ Endpoint.of(app1)
+ .targetRegion(ClusterSpec.Id.from("c1"), prodZone)
+ .routingMethod(RoutingMethod.exclusive)
+ .on(Port.tls())
+ .legacy()
.in(SystemName.Public)
);
tests.forEach((expected, endpoint) -> assertEquals(expected, endpoint.url().toString()));