diff options
author | Martin Polden <mpolden@mpolden.no> | 2021-05-05 17:12:50 +0200 |
---|---|---|
committer | Martin Polden <mpolden@mpolden.no> | 2021-05-05 17:37:10 +0200 |
commit | d1904b1f1559df4a08b117f1e1b9d852d6447b5f (patch) | |
tree | 396260b4148d022eaeb5a3d39e080f080c3bad5a /controller-server | |
parent | 8c61a373af0066fbdf1cca354c24b197c7347321 (diff) |
Include zone legacy endpoints
Diffstat (limited to 'controller-server')
4 files changed, 44 insertions, 16 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 c7cc0f361bc..7861c154a54 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 @@ -95,7 +95,7 @@ public class RoutingController { if (!policy.status().isActive()) continue; 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.addAll(policy.endpointsIn(controller.system(), routingMethod, controller.zoneRegistry())); endpoints.add(policy.regionEndpointIn(controller.system(), routingMethod)); } } @@ -140,7 +140,7 @@ public class RoutingController { public Map<ZoneId, List<Endpoint>> zoneEndpointsOf(Collection<DeploymentId> deployments) { var endpoints = new TreeMap<ZoneId, List<Endpoint>>(Comparator.comparing(ZoneId::value)); for (var deployment : deployments) { - EndpointList zoneEndpoints = endpointsOf(deployment).scope(Endpoint.Scope.zone); + EndpointList zoneEndpoints = endpointsOf(deployment).scope(Endpoint.Scope.zone).not().legacy(); zoneEndpoints = directEndpoints(zoneEndpoints, deployment.applicationId()); if ( ! zoneEndpoints.isEmpty()) { endpoints.put(deployment.zoneId(), zoneEndpoints.asList()); @@ -316,7 +316,7 @@ public class RoutingController { .on(Port.fromRoutingMethod(method)) .routingMethod(method) .in(controller.system())); - // TODO(mpolden): Remove this once all applications have migrated away from legacy endpoints + // Add legacy endpoints if (method == RoutingMethod.shared) { endpoints.add(Endpoint.of(routingId.application()) .target(routingId.endpointId(), cluster, zones) 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 898b2531460..0d1469a61fc 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 @@ -206,10 +206,11 @@ public class RoutingPolicies { /** Update zone DNS record for given policy */ private void updateZoneDnsOf(RoutingPolicy policy) { - var name = RecordName.from(policy.endpointIn(controller.system(), RoutingMethod.exclusive, controller.zoneRegistry()) - .dnsName()); - var data = RecordData.fqdn(policy.canonicalName().value()); - nameServiceForwarderIn(policy.id().zone()).createCname(name, data, Priority.normal); + for (var endpoint : policy.endpointsIn(controller.system(), RoutingMethod.exclusive, controller.zoneRegistry())) { + var name = RecordName.from(endpoint.dnsName()); + var data = RecordData.fqdn(policy.canonicalName().value()); + nameServiceForwarderIn(policy.id().zone()).createCname(name, data, Priority.normal); + } } /** Remove policies and zone DNS records unreferenced by given load balancers */ @@ -221,11 +222,12 @@ public class RoutingPolicies { // Leave active load balancers and irrelevant zones alone if (activeIds.contains(policy.id()) || !policy.id().zone().equals(allocation.deployment.zoneId())) continue; - - var dnsName = policy.endpointIn(controller.system(), RoutingMethod.exclusive, controller.zoneRegistry()).dnsName(); - nameServiceForwarderIn(allocation.deployment.zoneId()).removeRecords(Record.Type.CNAME, - RecordName.from(dnsName), - Priority.normal); + for (var endpoint : policy.endpointsIn(controller.system(), RoutingMethod.exclusive, controller.zoneRegistry())) { + var dnsName = endpoint.dnsName(); + nameServiceForwarderIn(allocation.deployment.zoneId()).removeRecords(Record.Type.CNAME, + RecordName.from(dnsName), + Priority.normal); + } newPolicies.remove(policy.id()); } db.writeRoutingPolicies(allocation.deployment.applicationId(), newPolicies); 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 a0fecbdf9e1..3ece10337f1 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 @@ -11,6 +11,8 @@ import com.yahoo.vespa.hosted.controller.application.Endpoint.Port; import com.yahoo.vespa.hosted.controller.application.EndpointId; import com.yahoo.vespa.hosted.controller.application.SystemApplication; +import java.util.ArrayList; +import java.util.List; import java.util.Objects; import java.util.Optional; import java.util.Set; @@ -69,12 +71,28 @@ public class RoutingPolicy { return new RoutingPolicy(id, canonicalName, dnsZone, endpoints, status); } - /** Returns the zone endpoint of this */ - public Endpoint endpointIn(SystemName system, RoutingMethod routingMethod, ZoneRegistry zoneRegistry) { + /** Returns the zone endpoints of this */ + public List<Endpoint> endpointsIn(SystemName system, RoutingMethod routingMethod, ZoneRegistry zoneRegistry) { Optional<Endpoint> infraEndpoint = SystemApplication.matching(id.owner()) .flatMap(app -> app.endpointIn(id.zone(), zoneRegistry)); - return infraEndpoint.orElseGet(() -> endpoint(routingMethod).target(id.cluster(), id.zone()) - .in(system)); + List<Endpoint> endpoints = new ArrayList<>(3); + if (infraEndpoint.isPresent()) { + endpoints.add(infraEndpoint.get()); + } else { + endpoints.add(endpoint(routingMethod).target(id.cluster(), id.zone()).in(system)); + // Add legacy endpoints + if (routingMethod == RoutingMethod.shared) { + endpoints.add(endpoint(routingMethod).target(id.cluster(), id.zone()) + .on(Port.plain(4080)) + .legacy() + .in(system)); + endpoints.add(endpoint(routingMethod).target(id.cluster(), id.zone()) + .on(Port.tls(4443)) + .legacy() + .in(system)); + } + } + return endpoints; } /** Returns the region endpoint of this */ 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 0c0d1d80adb..195b87caf34 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 @@ -896,6 +896,14 @@ public class ControllerTest { "application--tenant.global.vespa.oath.cloud"), tester.configServer().containerEndpoints().get(context.deploymentIdIn(zone))); } + List<String> zoneDnsNames = tester.controller().routing().endpointsOf(context.deploymentIdIn(zone1)) + .scope(Endpoint.Scope.zone) + .mapToList(Endpoint::dnsName); + assertEquals(List.of("application--tenant.us-west-1.vespa.oath.cloud", + "application.tenant.us-west-1.prod.vespa.yahooapis.com", + "application--tenant.us-west-1.prod.vespa.yahooapis.com", + "application.tenant.us-west-1.vespa.oath.cloud"), + zoneDnsNames); } @Test |