diff options
author | Morten Tokle <mortent@verizonmedia.com> | 2020-06-15 17:46:51 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-06-15 17:46:51 +0200 |
commit | ba5d6c161d9d4ff9bd3a3f8237102a688558febe (patch) | |
tree | aa17cc8b1865d4d2b5a67103cf14993a1c636b33 | |
parent | 6ee498d929b54202ea4b8881336bc6aa6dda7aa4 (diff) | |
parent | 45eeafc5af665609d7f45bff6d73bac51adaddbf (diff) |
Merge pull request #13593 from vespa-engine/mpolden/support-legacy-syntax
Create global routing policy with legacy syntax
2 files changed, 26 insertions, 1 deletions
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 abd4770ea0d..9678c42d31f 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 @@ -289,12 +289,16 @@ public class RoutingPolicies { if (instanceSpec.isEmpty()) { return Set.of(); } + if (instanceSpec.get().globalServiceId().filter(id -> id.equals(loadBalancer.cluster().value())).isPresent()) { + // Legacy assignment always has the default endpoint Id + return Set.of(EndpointId.defaultId()); + } return instanceSpec.get().endpoints().stream() .filter(endpoint -> endpoint.containerId().equals(loadBalancer.cluster().value())) .filter(endpoint -> endpoint.regions().contains(deployment.zoneId().region())) .map(com.yahoo.config.application.api.Endpoint::endpointId) .map(EndpointId::of) - .collect(Collectors.toSet()); + .collect(Collectors.toUnmodifiableSet()); } } 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 56fb7194e4e..a026a3c75a2 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 @@ -138,6 +138,27 @@ public class RoutingPoliciesTest { } @Test + public void global_routing_policies_legacy_global_service_id() { + var tester = new RoutingPoliciesTester(); + var context = tester.newDeploymentContext("tenant1", "app1", "default"); + int clustersPerZone = 2; + int numberOfDeployments = 2; + var applicationPackage = applicationPackageBuilder() + .region(zone1.region()) + .region(zone2.region()) + .globalServiceId("c0") + .build(); + tester.provisionLoadBalancers(clustersPerZone, context.instanceId(), zone1, zone2); + + // Creates alias records + context.submit(applicationPackage).deferLoadBalancerProvisioningIn(Environment.prod).deploy(); + tester.assertTargets(context.instanceId(), EndpointId.defaultId(), 0, zone1, zone2); + assertEquals("Routing policy count is equal to cluster count", + numberOfDeployments * clustersPerZone, + tester.policiesOf(context.instance().id()).size()); + } + + @Test public void zone_routing_policies() { zone_routing_policies(false); zone_routing_policies(true); |