diff options
author | toby <smorgrav@yahoo-inc.com> | 2018-10-04 09:38:01 +0200 |
---|---|---|
committer | toby <smorgrav@yahoo-inc.com> | 2018-10-04 09:38:01 +0200 |
commit | e9d5eadda69dcc2e3619ba7fcf5473e27f323c24 (patch) | |
tree | 91ded799073f352cf5883bf0ce13f3aa83051ed9 /controller-server | |
parent | 34a575c8292deeefed1974ccc6ad89bab9587bee (diff) |
Add method to look up multiple records by name and apply this
Diffstat (limited to 'controller-server')
-rw-r--r-- | controller-server/src/main/java/com/yahoo/vespa/hosted/controller/ApplicationController.java | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/ApplicationController.java b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/ApplicationController.java index c2dbc8bdc59..c695b1a838c 100644 --- a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/ApplicationController.java +++ b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/ApplicationController.java @@ -95,6 +95,7 @@ public class ApplicationController { private final RotationRepository rotationRepository; private final AthenzClientFactory zmsClientFactory; private final NameService nameService; + private final NameService newNameService; private final ConfigServer configServer; private final RoutingGenerator routingGenerator; private final Clock clock; @@ -103,13 +104,14 @@ public class ApplicationController { ApplicationController(Controller controller, CuratorDb curator, AthenzClientFactory zmsClientFactory, RotationsConfig rotationsConfig, - NameService nameService, ConfigServer configServer, + NameService nameService, NameService newNameService, ConfigServer configServer, ArtifactRepository artifactRepository, ApplicationStore applicationStore, RoutingGenerator routingGenerator, BuildService buildService, Clock clock) { this.controller = controller; this.curator = curator; this.zmsClientFactory = zmsClientFactory; this.nameService = nameService; + this.newNameService = newNameService; this.configServer = configServer; this.routingGenerator = routingGenerator; this.clock = clock; @@ -482,16 +484,19 @@ public class ApplicationController { /** Register a DNS name for rotation */ private void registerRotationInDns(Rotation rotation, String dnsName) { try { - Optional<Record> record = nameService.findRecord(Record.Type.CNAME, RecordName.from(dnsName)); + RecordData rotationName = RecordData.fqdn(rotation.name()); - if (record.isPresent()) { + List<Record> records = nameService.findRecords(Record.Type.CNAME, RecordName.from(dnsName)); + records.forEach(record -> { // Ensure that the existing record points to the correct rotation - if ( ! record.get().data().equals(rotationName)) { - nameService.updateRecord(record.get().id(), rotationName); - log.info("Updated mapping for record ID " + record.get().id().asString() + ": '" + dnsName - + "' -> '" + rotation.name() + "'"); + if ( ! record.data().equals(rotationName)) { + nameService.updateRecord(record.id(), rotationName); + log.info("Updated mapping for record ID " + record.id().asString() + ": '" + dnsName + + "' -> '" + rotation.name() + "'"); } - } else { + }); + + if (records.isEmpty()) { RecordId id = nameService.createCname(RecordName.from(dnsName), rotationName); log.info("Registered mapping with record ID " + id.asString() + ": '" + dnsName + "' -> '" + rotation.name() + "'"); |