diff options
author | Martin Polden <mpolden@mpolden.no> | 2023-07-13 09:50:02 +0200 |
---|---|---|
committer | Martin Polden <mpolden@mpolden.no> | 2023-07-13 09:51:55 +0200 |
commit | b9f0ba923b46f567aeddd5a40a8d630cdeb4dd39 (patch) | |
tree | bd3a3a9f060e3d92e1bc42bb871a9a82a38a9865 /controller-server/src | |
parent | ff24c1aa0e15597c1b610b26ee2d8d4f9ee61cb3 (diff) |
Remove unreferenced region-wide endpoints
Diffstat (limited to 'controller-server/src')
2 files changed, 20 insertions, 5 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 b35e8e5a638..a309afcd039 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 @@ -118,7 +118,7 @@ public class RoutingPolicies { RoutingPolicyList applicationPolicies = read(TenantAndApplicationId.from(instance)); RoutingPolicyList deploymentPolicies = applicationPolicies.deployment(allocation.deployment); - removeGlobalDnsUnreferencedBy(allocation, deploymentPolicies, lock); + removeGlobalDnsUnreferencedBy(allocation, deploymentPolicies, inactiveZones, lock); removeApplicationDnsUnreferencedBy(allocation, deploymentPolicies, lock); RoutingPolicyList instancePolicies = storePoliciesOf(allocation, applicationPolicies, generatedEndpoints, lock); @@ -489,7 +489,7 @@ public class RoutingPolicies { } /** Remove unreferenced instance endpoints from DNS */ - private void removeGlobalDnsUnreferencedBy(LoadBalancerAllocation allocation, RoutingPolicyList deploymentPolicies, @SuppressWarnings("unused") Mutex lock) { + private void removeGlobalDnsUnreferencedBy(LoadBalancerAllocation allocation, RoutingPolicyList deploymentPolicies, Set<ZoneId> inactiveZones, @SuppressWarnings("unused") Mutex lock) { Set<RoutingId> removalCandidates = new HashSet<>(deploymentPolicies.asInstanceRoutingTable().keySet()); Set<RoutingId> activeRoutingIds = instanceRoutingIds(allocation); removalCandidates.removeAll(activeRoutingIds); @@ -499,9 +499,18 @@ public class RoutingPolicies { .named(id.endpointId(), Endpoint.Scope.global); // This removes all ALIAS records having this DNS name. There is no attempt to delete only the entry for the // affected zone. Instead, the correct set of records is (re)created by updateGlobalDnsOf - endpoints.forEach(endpoint -> nameServiceForwarder(endpoint).removeRecords(Record.Type.ALIAS, RecordName.from(endpoint.dnsName()), - Priority.normal, - ownerOf(allocation))); + for (var endpoint : endpoints) { + for (var regionEndpoint : computeRegionEndpoints(endpoint, deploymentPolicies.asList(), inactiveZones)) { + Record.Type type = regionEndpoint.zoneDirectTargets().isEmpty() ? Record.Type.ALIAS : Record.Type.DIRECT; + controller.nameServiceForwarder().removeRecords(type, + RecordName.from(regionEndpoint.target().name().value()), + Priority.normal, + ownerOf(allocation)); + } + nameServiceForwarder(endpoint).removeRecords(Record.Type.ALIAS, RecordName.from(endpoint.dnsName()), + Priority.normal, + ownerOf(allocation)); + } } } 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 0a6d2a3b106..02f030aa758 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 @@ -441,6 +441,12 @@ public class RoutingPoliciesTest { assertEquals(List.of("latency/c0.app1.tenant1.aws-us-east-1.w.vespa-app.cloud/dns-zone-1/prod.aws-us-east-1c", "latency/c0.app1.tenant1.gcp-us-south1.w.vespa-app.cloud/ignored/prod.gcp-us-south1-b"), tester.recordDataOf(Record.Type.ALIAS, expectedRecords.get(4))); + + // Application is removed and records are cleaned up + tester.controllerTester().controller().applications().requireInstance(context.instanceId()).deployments().keySet() + .forEach(zone -> tester.controllerTester().controller().applications().deactivate(context.instanceId(), zone)); + context.flushDnsUpdates(); + assertEquals(List.of(), tester.recordNames()); } @Test |