diff options
author | jonmv <venstad@gmail.com> | 2023-01-27 09:17:28 +0100 |
---|---|---|
committer | jonmv <venstad@gmail.com> | 2023-01-27 09:17:28 +0100 |
commit | 78a42e1cf9735f58e7f204f34e0cb2bd7c1a3674 (patch) | |
tree | b6c5f1b15ad3729fd8cf10a5e8dd10b2e72d9f0e /controller-api | |
parent | b44b2ce5fd913f56d781dba9efe7cb6006584a7d (diff) |
Refactor endpoint verification during deployments
Diffstat (limited to 'controller-api')
2 files changed, 12 insertions, 8 deletions
diff --git a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/deployment/TesterCloud.java b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/deployment/TesterCloud.java index b4d9dd49880..edc5faefe65 100644 --- a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/deployment/TesterCloud.java +++ b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/deployment/TesterCloud.java @@ -2,6 +2,8 @@ package com.yahoo.vespa.hosted.controller.api.integration.deployment; import ai.vespa.http.DomainName; +import com.yahoo.config.provision.EndpointsChecker.Endpoint; +import com.yahoo.config.provision.EndpointsChecker.UnavailabilityCause; import com.yahoo.config.provision.Environment; import com.yahoo.vespa.hosted.controller.api.identifiers.DeploymentId; import com.yahoo.vespa.hosted.controller.api.integration.LogEntry; @@ -33,11 +35,7 @@ public interface TesterCloud { /** Returns whether the test container is ready to serve */ boolean testerReady(DeploymentId deploymentId); - /** Returns the IP address of the given host name, if any. */ - Optional<InetAddress> resolveHostName(DomainName hostname); - - /** Returns the host name of the given CNAME, if any. */ - Optional<DomainName> resolveCname(DomainName hostName); + Optional<UnavailabilityCause> verifyEndpoints(List<Endpoint> endpoints); /** Returns the test report as JSON if available */ Optional<TestReport> getTestReport(DeploymentId deploymentId); 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 939c74fe61d..7a819ecc1db 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 @@ -3,6 +3,9 @@ package com.yahoo.vespa.hosted.controller.api.integration.stubs; import ai.vespa.http.DomainName; import com.google.common.net.InetAddresses; +import com.yahoo.config.provision.EndpointsChecker; +import com.yahoo.config.provision.EndpointsChecker.Endpoint; +import com.yahoo.config.provision.EndpointsChecker.UnavailabilityCause; 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; @@ -59,15 +62,18 @@ public class MockTesterCloud implements TesterCloud { } @Override - public Optional<InetAddress> resolveHostName(DomainName hostname) { + public Optional<UnavailabilityCause> verifyEndpoints(List<Endpoint> endpoints) { + return EndpointsChecker.endpointsAvailable(endpoints, this::resolveHostName, this::resolveCname); + } + + private Optional<InetAddress> resolveHostName(DomainName hostname) { 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 - public Optional<DomainName> resolveCname(DomainName hostName) { + private Optional<DomainName> resolveCname(DomainName hostName) { return nameService.findRecords(Record.Type.CNAME, RecordName.from(hostName.value())).stream() .findFirst() .map(record -> DomainName.of(record.data().asString().substring(0, record.data().asString().length() - 1))); |