summaryrefslogtreecommitdiffstats
path: root/controller-api
diff options
context:
space:
mode:
authorValerij Fredriksen <valerijf@yahooinc.com>2022-10-05 14:26:15 +0200
committerValerij Fredriksen <valerijf@yahooinc.com>2022-10-06 12:53:01 +0200
commite0bf67c8b8a9842ecb59cd9516a44fcc155716bc (patch)
treee7b0449a69789bff34b08a466ba799b273107a2b /controller-api
parent522f279ee81dd86f29fe5db56d600ebba1d3dcfc (diff)
Allow creating A records
Diffstat (limited to 'controller-api')
-rw-r--r--controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/dns/MemoryNameService.java4
-rw-r--r--controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/dns/NameService.java9
-rw-r--r--controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/stubs/MockTesterCloud.java12
3 files changed, 12 insertions, 13 deletions
diff --git a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/dns/MemoryNameService.java b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/dns/MemoryNameService.java
index 18ff3f18137..18d7bc53035 100644
--- a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/dns/MemoryNameService.java
+++ b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/dns/MemoryNameService.java
@@ -33,8 +33,8 @@ public class MemoryNameService implements NameService {
}
@Override
- public Record createCname(RecordName name, RecordData canonicalName) {
- var record = new Record(Record.Type.CNAME, name, canonicalName);
+ public Record createRecord(Record.Type type, RecordName name, RecordData canonicalName) {
+ var record = new Record(type, name, canonicalName);
add(record);
return record;
}
diff --git a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/dns/NameService.java b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/dns/NameService.java
index eac657d8b75..505ff3850ab 100644
--- a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/dns/NameService.java
+++ b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/dns/NameService.java
@@ -12,13 +12,14 @@ import java.util.Set;
public interface NameService {
/**
- * Create a new CNAME record
+ * Create a new record
*
- * @param name The alias to create (lhs of the record)
- * @param canonicalName The canonical name which the alias should point to (rhs of the record). This must be a FQDN.
+ * @param type The DNS type of record to make, only a small set of types are supported, check with the implementation
+ * @param name Name of the record, e.g. a FQDN for records of type A
+ * @param data Data of the record, e.g. IP address for records of type A
* @return The created record
*/
- Record createCname(RecordName name, RecordData canonicalName);
+ Record createRecord(Record.Type type, RecordName name, RecordData data);
/**
* Create a non-standard ALIAS record pointing to given targets. Implementations of this are expected to be
diff --git a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/stubs/MockTesterCloud.java b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/stubs/MockTesterCloud.java
index 63c2388b461..e53be91f94b 100644
--- a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/stubs/MockTesterCloud.java
+++ b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/stubs/MockTesterCloud.java
@@ -2,6 +2,7 @@
package com.yahoo.vespa.hosted.controller.api.integration.stubs;
import ai.vespa.http.DomainName;
+import com.google.common.net.InetAddresses;
import com.yahoo.vespa.hosted.controller.api.identifiers.DeploymentId;
import com.yahoo.vespa.hosted.controller.api.integration.LogEntry;
import com.yahoo.vespa.hosted.controller.api.integration.deployment.TestReport;
@@ -12,7 +13,6 @@ import com.yahoo.vespa.hosted.controller.api.integration.dns.RecordName;
import java.net.InetAddress;
import java.net.URI;
-import java.net.UnknownHostException;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
@@ -60,12 +60,10 @@ public class MockTesterCloud implements TesterCloud {
@Override
public Optional<InetAddress> resolveHostName(DomainName hostname) {
- try {
- return Optional.of(InetAddress.getByAddress(new byte[]{ 1, 2, 3, 4 }));
- }
- catch (UnknownHostException e) {
- throw new IllegalStateException("should not happen");
- }
+ return nameService.findRecords(Record.Type.A, RecordName.from(hostname.value())).stream()
+ .findFirst()
+ .map(record -> InetAddresses.forString(record.data().asString()))
+ .or(() -> Optional.of(InetAddresses.forString("1.2.3.4")));
}
@Override