aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin Polden <mpolden@mpolden.no>2023-09-28 10:47:03 +0200
committerMartin Polden <mpolden@mpolden.no>2023-09-28 10:47:03 +0200
commitcecbf4103abb330efe4135a552f0744c9828dba4 (patch)
tree5712bc1df90a32ca3e47465da9bb6ba48c8ce041
parentab59791b8d0182278486334001aa344903bebb32 (diff)
Avoid transient error when migrating to generated endpoint
-rw-r--r--controller-server/src/main/java/com/yahoo/vespa/hosted/controller/routing/RoutingPolicies.java6
-rw-r--r--controller-server/src/test/java/com/yahoo/vespa/hosted/controller/routing/RoutingPoliciesTest.java26
2 files changed, 32 insertions, 0 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 be9d077183b..7caf8e8d542 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
@@ -263,6 +263,12 @@ public class RoutingPolicies {
} else {
weightedEndpoints = weightedEndpoints.not().generated();
}
+ if (generated && weightedEndpoints.isEmpty()) {
+ // Ignore this policy. If an instance has a global endpoint, and is switching from non-generated to
+ // generated endpoints we cannot update global DNS record for a deployment until it has been deployed at
+ // least once (which assigns a generated endpoint).
+ continue;
+ }
if (weightedEndpoints.size() != 1) {
throw new IllegalStateException("Expected to compute exactly one region endpoint for " + policy.id() + " with parent " + parent + ", got " + weightedEndpoints);
}
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 4c5781d2d23..37feb319a7a 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
@@ -1237,6 +1237,32 @@ public class RoutingPoliciesTest {
assertEquals(List.of(), tester.recordNames());
}
+ @Test
+ public void generated_endpoint_migration_with_global_endpoint() {
+ var tester = new RoutingPoliciesTester(SystemName.Public);
+ var context = tester.newDeploymentContext("tenant1", "app1", "default");
+ addCertificateToPool("cafed00d", UnassignedCertificate.State.ready, tester);
+
+ // Deploy application
+ int clustersPerZone = 2;
+ var zone1 = ZoneId.from("prod", "aws-us-east-1c");
+ var zone2 = ZoneId.from("prod", "aws-eu-west-1a");
+ ApplicationPackage applicationPackage = applicationPackageBuilder().region(zone1.region())
+ .region(zone2.region())
+ .container("c0", AuthMethod.mtls)
+ .endpoint("foo", "c0")
+ .build();
+ tester.provisionLoadBalancers(clustersPerZone, context.instanceId(), zone1, zone2);
+ context.submit(applicationPackage).deferLoadBalancerProvisioningIn(Environment.prod).deploy();
+ tester.assertTargets(context.instanceId(), EndpointId.of("foo"), 0, zone1, zone2);
+
+ // Switch to generated
+ tester.controllerTester().flagSource().withBooleanFlag(Flags.RANDOMIZED_ENDPOINT_NAMES.id(), true);
+ context.submit(applicationPackage).deferLoadBalancerProvisioningIn(Environment.prod).deploy();
+ tester.assertTargets(context.instance().id(), EndpointId.of("foo"), ClusterSpec.Id.from("c0"),
+ 0, Map.of(zone1, 1L, zone2, 1L), true);
+ }
+
private void addCertificateToPool(String id, UnassignedCertificate.State state, RoutingPoliciesTester tester) {
EndpointCertificate cert = new EndpointCertificate("testKey", "testCert", 1, 0,
"request-id",