summaryrefslogtreecommitdiffstats
path: root/controller-server
diff options
context:
space:
mode:
authorMartin Polden <mpolden@mpolden.no>2020-07-22 15:08:41 +0200
committerGitHub <noreply@github.com>2020-07-22 15:08:41 +0200
commit7973c1ec0805711dd568e46c59e7b99bb36696dc (patch)
treedc627f6cd89347ec11b6ad54f2049fb49fa09e77 /controller-server
parent64257fe90d37048dbdd38f8ae4fe775696548de4 (diff)
parentf49afea79c89729ddb263a215f9d82b2eec7a6aa (diff)
Merge pull request #13935 from vespa-engine/mpolden/rename-scope
Rename endpoint scope weighted -> region
Diffstat (limited to 'controller-server')
-rw-r--r--controller-server/src/main/java/com/yahoo/vespa/hosted/controller/RoutingController.java2
-rw-r--r--controller-server/src/main/java/com/yahoo/vespa/hosted/controller/application/Endpoint.java16
-rw-r--r--controller-server/src/main/java/com/yahoo/vespa/hosted/controller/application/EndpointList.java6
-rw-r--r--controller-server/src/main/java/com/yahoo/vespa/hosted/controller/restapi/application/ApplicationApiHandler.java9
-rw-r--r--controller-server/src/main/java/com/yahoo/vespa/hosted/controller/routing/RoutingPolicies.java8
-rw-r--r--controller-server/src/main/java/com/yahoo/vespa/hosted/controller/routing/RoutingPolicy.java8
-rw-r--r--controller-server/src/test/java/com/yahoo/vespa/hosted/controller/application/EndpointTest.java8
-rw-r--r--controller-server/src/test/java/com/yahoo/vespa/hosted/controller/routing/RoutingPoliciesTest.java16
8 files changed, 40 insertions, 33 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 19d55d35f2f..26270c092d5 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
@@ -89,7 +89,7 @@ public class RoutingController {
for (var routingMethod : controller.zoneRegistry().routingMethods(policy.id().zone())) {
if (routingMethod.isDirect() && !isSystemApplication && !canRouteDirectlyTo(deployment, application.get())) continue;
endpoints.add(policy.endpointIn(controller.system(), routingMethod, controller.zoneRegistry()));
- endpoints.add(policy.weightedEndpointIn(controller.system(), routingMethod));
+ endpoints.add(policy.regionEndpointIn(controller.system(), routingMethod));
}
}
return EndpointList.copyOf(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 aaaeb4218ec..341bf7de9d6 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
@@ -205,7 +205,7 @@ public class Endpoint {
if (scope == Scope.global) return "global";
var zone = zones.get(0);
var region = zone.region().value();
- if (scope == Scope.weighted) region += "-w";
+ if (scope == Scope.region) region += "-w";
if (!legacy && zone.environment().isProduction()) return region; // Skip prod environment for non-legacy endpoints
return region + "." + zone.environment().value();
}
@@ -276,15 +276,15 @@ public class Endpoint {
/** An endpoint's scope */
public enum Scope {
- /** Endpoint points to all zones */
+ /** Endpoint points to one or more zones. Traffic is routed to the zone closest to the client */
global,
+ /** Endpoint points to one more zones in the same geographical region. Traffic is routed equally across zones */
+ region,
+
/** Endpoint points to a single zone */
zone,
- /** Endpoint points to a single region */
- weighted,
-
}
/** Represents an endpoint's HTTP port */
@@ -391,11 +391,11 @@ public class Endpoint {
return target(ClusterSpec.Id.from("*"), zone);
}
- /** Sets the weighted target for this */
- public EndpointBuilder weighted(ClusterSpec.Id cluster, ZoneId zone) {
+ /** Sets the region target for this, deduced from given zone */
+ public EndpointBuilder targetRegion(ClusterSpec.Id cluster, ZoneId zone) {
checkScope();
this.cluster = cluster;
- this.scope = Scope.weighted;
+ this.scope = Scope.region;
this.zones = List.of(effectiveZone(zone));
return this;
}
diff --git a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/application/EndpointList.java b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/application/EndpointList.java
index 4da34dad737..e847667bf45 100644
--- a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/application/EndpointList.java
+++ b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/application/EndpointList.java
@@ -2,6 +2,7 @@
package com.yahoo.vespa.hosted.controller.application;
import com.yahoo.collections.AbstractFilteringList;
+import com.yahoo.config.provision.ClusterSpec;
import com.yahoo.config.provision.zone.ZoneId;
import java.util.Collection;
@@ -33,6 +34,11 @@ public class EndpointList extends AbstractFilteringList<Endpoint, EndpointList>
return matching(endpoint -> endpoint.name().equals(id.id()));
}
+ /** Returns the subset of endpoints pointing to given cluster */
+ public EndpointList cluster(ClusterSpec.Id cluster) {
+ return matching(endpoint -> endpoint.cluster().equals(cluster));
+ }
+
/** Returns the subset of endpoints which target all of the given zones */
public EndpointList targets(List<ZoneId> zones) {
return matching(endpoint -> endpoint.zones().containsAll(zones));
diff --git a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/restapi/application/ApplicationApiHandler.java b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/restapi/application/ApplicationApiHandler.java
index afd56d8f5d8..5b35a1aa5c1 100644
--- a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/restapi/application/ApplicationApiHandler.java
+++ b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/restapi/application/ApplicationApiHandler.java
@@ -956,8 +956,8 @@ public class ApplicationApiHandler extends LoggingRequestHandler {
.ifPresent(version -> toSlime(version, object.setObject("revision")));
}
- private void toSlime(Endpoint endpoint, String cluster, Cursor object) {
- object.setString("cluster", cluster);
+ private void toSlime(Endpoint endpoint, Cursor object) {
+ object.setString("cluster", endpoint.cluster().value());
object.setBool("tls", endpoint.tls());
object.setString("url", endpoint.url().toString());
object.setString("scope", endpointScopeString(endpoint.scope()));
@@ -977,14 +977,14 @@ public class ApplicationApiHandler extends LoggingRequestHandler {
for (var endpoint : controller.routing().endpointsOf(deploymentId)
.scope(Endpoint.Scope.zone)
.not().legacy()) {
- toSlime(endpoint, endpoint.name(), endpointArray.addObject());
+ toSlime(endpoint, endpointArray.addObject());
}
// Add global endpoints
var globalEndpoints = controller.routing().endpointsOf(application, deploymentId.applicationId().instance())
.not().legacy()
.targets(deploymentId.zoneId());
for (var endpoint : globalEndpoints) {
- toSlime(endpoint, endpoint.cluster().value(), endpointArray.addObject());
+ toSlime(endpoint, endpointArray.addObject());
}
response.setString("nodes", withPath("/zone/v2/" + deploymentId.zoneId().environment() + "/" + deploymentId.zoneId().region() + "/nodes/v2/node/?&recursive=true&application=" + deploymentId.applicationId().tenant() + "." + deploymentId.applicationId().application() + "." + deploymentId.applicationId().instance(), request.getUri()).toString());
@@ -1957,6 +1957,7 @@ public class ApplicationApiHandler extends LoggingRequestHandler {
private static String endpointScopeString(Endpoint.Scope scope) {
switch (scope) {
+ case region: return "region";
case global: return "global";
case zone: return "zone";
}
diff --git a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/routing/RoutingPolicies.java b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/routing/RoutingPolicies.java
index 2a42bd9c235..0356e11ae36 100644
--- a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/routing/RoutingPolicies.java
+++ b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/routing/RoutingPolicies.java
@@ -166,7 +166,7 @@ public class RoutingPolicies {
for (var policy : policies) {
if (policy.dnsZone().isEmpty()) continue;
if (!controller.zoneRegistry().routingMethods(policy.id().zone()).contains(routingMethod)) continue;
- Endpoint weighted = policy.weightedEndpointIn(controller.system(), routingMethod);
+ Endpoint regionEndpoint = policy.regionEndpointIn(controller.system(), routingMethod);
var zonePolicy = db.readZoneRoutingPolicy(policy.id().zone());
long weight = 1;
if (isConfiguredOut(policy, zonePolicy, inactiveZones)) {
@@ -175,9 +175,9 @@ public class RoutingPolicies {
}
var weightedTarget = new WeightedAliasTarget(policy.canonicalName(), policy.dnsZone().get(),
policy.id().zone(), weight);
- endpoints.computeIfAbsent(weighted, (k) -> new RegionEndpoint(new LatencyAliasTarget(HostName.from(weighted.dnsName()),
- policy.dnsZone().get(),
- policy.id().zone())))
+ endpoints.computeIfAbsent(regionEndpoint, (k) -> new RegionEndpoint(new LatencyAliasTarget(HostName.from(regionEndpoint.dnsName()),
+ policy.dnsZone().get(),
+ policy.id().zone())))
.zoneTargets()
.add(weightedTarget);
}
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 337e2b897f1..f87c6e2d11c 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
@@ -69,7 +69,7 @@ public class RoutingPolicy {
return new RoutingPolicy(id, canonicalName, dnsZone, endpoints, status);
}
- /** Returns the endpoint of this */
+ /** Returns the zone endpoint of this */
public Endpoint endpointIn(SystemName system, RoutingMethod routingMethod, ZoneRegistry zoneRegistry) {
Optional<Endpoint> infraEndpoint = SystemApplication.matching(id.owner())
.flatMap(app -> app.endpointIn(id.zone(), zoneRegistry));
@@ -77,9 +77,9 @@ public class RoutingPolicy {
return endpoint(routingMethod).target(id.cluster(), id.zone()).in(system);
}
- /** Returns the weighted endpoint of this */
- public Endpoint weightedEndpointIn(SystemName system, RoutingMethod routingMethod) {
- return endpoint(routingMethod).weighted(id.cluster(), id.zone()).in(system);
+ /** Returns the region endpoint of this */
+ public Endpoint regionEndpointIn(SystemName system, RoutingMethod routingMethod) {
+ return endpoint(routingMethod).targetRegion(id.cluster(), id.zone()).in(system);
}
@Override
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 2f4c9af54c3..eb97fa0725c 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
@@ -233,26 +233,26 @@ public class EndpointTest {
Map<String, Endpoint> tests = Map.of(
"https://a1.t1.us-north-1-w.public.vespa.oath.cloud/",
Endpoint.of(app1)
- .weighted(cluster, ZoneId.from("prod", "us-north-1a"))
+ .targetRegion(cluster, ZoneId.from("prod", "us-north-1a"))
.routingMethod(RoutingMethod.exclusive)
.on(Port.tls())
.in(SystemName.Public),
"https://a1.t1.us-north-2-w.public.vespa.oath.cloud/",
Endpoint.of(app1)
- .weighted(cluster, ZoneId.from("prod", "us-north-2"))
+ .targetRegion(cluster, ZoneId.from("prod", "us-north-2"))
.routingMethod(RoutingMethod.exclusive)
.on(Port.tls())
.in(SystemName.Public),
"https://a1.t1.us-north-2-w.test.public.vespa.oath.cloud/",
Endpoint.of(app1)
- .weighted(cluster, ZoneId.from("test", "us-north-2"))
+ .targetRegion(cluster, ZoneId.from("test", "us-north-2"))
.routingMethod(RoutingMethod.exclusive)
.on(Port.tls())
.in(SystemName.Public)
);
tests.forEach((expected, endpoint) -> assertEquals(expected, endpoint.url().toString()));
Endpoint endpoint = Endpoint.of(app1)
- .weighted(cluster, ZoneId.from("prod", "us-north-1a"))
+ .targetRegion(cluster, ZoneId.from("prod", "us-north-1a"))
.routingMethod(RoutingMethod.exclusive)
.on(Port.tls())
.in(SystemName.main);
diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/routing/RoutingPoliciesTest.java b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/routing/RoutingPoliciesTest.java
index c58003cd781..fab61eeaec3 100644
--- a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/routing/RoutingPoliciesTest.java
+++ b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/routing/RoutingPoliciesTest.java
@@ -785,16 +785,16 @@ public class RoutingPoliciesTest {
.collect(Collectors.toList());
}
- private void assertTargets(ApplicationId application, EndpointId endpointId, ClusterSpec.Id clusterId, int loadBalancerId, Map<ZoneId, Long> zoneWeights) {
+ private void assertTargets(ApplicationId application, EndpointId endpointId, ClusterSpec.Id cluster, int loadBalancerId, Map<ZoneId, Long> zoneWeights) {
Set<String> latencyTargets = new HashSet<>();
Map<String, List<ZoneId>> zonesByRegionEndpoint = new HashMap<>();
for (var zone : zoneWeights.keySet()) {
- Endpoint weighted = tester.controller().routing().endpointsOf(new DeploymentId(application, zone))
- .scope(Endpoint.Scope.weighted)
- .named(EndpointId.of(clusterId.value()))
- .asList()
- .get(0);
- zonesByRegionEndpoint.computeIfAbsent(weighted.dnsName(), (k) -> new ArrayList<>())
+ Endpoint regionEndpoint = tester.controller().routing().endpointsOf(new DeploymentId(application, zone))
+ .scope(Endpoint.Scope.region)
+ .cluster(cluster)
+ .asList()
+ .get(0);
+ zonesByRegionEndpoint.computeIfAbsent(regionEndpoint.dnsName(), (k) -> new ArrayList<>())
.add(zone);
}
zonesByRegionEndpoint.forEach((regionEndpoint, zonesInRegion) -> {
@@ -803,7 +803,7 @@ public class RoutingPoliciesTest {
application.serializedForm() + "--" + z.value() +
"/dns-zone-1/" + z.value() + "/" + zoneWeights.get(z))
.collect(Collectors.toSet());
- assertEquals("Weighted endpoint " + regionEndpoint + " points to load balancer",
+ assertEquals("Region endpoint " + regionEndpoint + " points to load balancer",
weightedTargets,
aliasDataOf(regionEndpoint));
ZoneId zone = zonesInRegion.get(0);