diff options
author | Harald Musum <musum@verizonmedia.com> | 2020-01-20 13:08:57 +0100 |
---|---|---|
committer | Harald Musum <musum@verizonmedia.com> | 2020-01-20 13:09:25 +0100 |
commit | 6668323fe09e42ec9c8aa848da4dd723c882971f (patch) | |
tree | a77fbf7fc2acd2a0522bd368a3d0a3db7d96f5b2 | |
parent | 0c6b28ef310bb5714b8c2ba10651ae87068e9b59 (diff) |
Route tester API calls based on feature flag
3 files changed, 29 insertions, 8 deletions
diff --git a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/configserver/ConfigServer.java b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/configserver/ConfigServer.java index 74e4ac9d404..a009f002954 100644 --- a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/configserver/ConfigServer.java +++ b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/configserver/ConfigServer.java @@ -11,6 +11,7 @@ import com.yahoo.vespa.hosted.controller.api.application.v4.model.EndpointStatus import com.yahoo.vespa.hosted.controller.api.identifiers.DeploymentId; import com.yahoo.vespa.hosted.controller.api.identifiers.Hostname; import com.yahoo.vespa.hosted.controller.api.integration.certificates.ApplicationCertificate; +import com.yahoo.vespa.hosted.controller.api.integration.deployment.TesterCloud; import com.yahoo.vespa.serviceview.bindings.ApplicationView; import java.io.InputStream; @@ -87,4 +88,8 @@ public interface ConfigServer { /** List all flag data for the given zone */ List<FlagData> listFlagData(ZoneId zone); + /** Gets status for tester application */ + // TODO: Remove default implementation when implemented in internal repo + default TesterCloud.Status getTesterStatus(DeploymentId deployment) { return TesterCloud.Status.SUCCESS; } + } diff --git a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/deployment/InternalStepRunner.java b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/deployment/InternalStepRunner.java index bd61d85fbc0..9d09394a571 100644 --- a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/deployment/InternalStepRunner.java +++ b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/deployment/InternalStepRunner.java @@ -17,6 +17,9 @@ import com.yahoo.security.KeyUtils; import com.yahoo.security.SignatureAlgorithm; import com.yahoo.security.X509CertificateBuilder; import com.yahoo.security.X509CertificateUtils; +import com.yahoo.vespa.flags.BooleanFlag; +import com.yahoo.vespa.flags.FetchVector; +import com.yahoo.vespa.flags.Flags; import com.yahoo.vespa.hosted.controller.Application; import com.yahoo.vespa.hosted.controller.Controller; import com.yahoo.vespa.hosted.controller.Instance; @@ -469,7 +472,7 @@ public class InternalStepRunner implements StepRunner { } private Optional<RunStatus> endTests(RunId id, DualLogger logger) { - if ( ! deployment(id.application(), id.type()).isPresent()) { + if (deployment(id.application(), id.type()).isEmpty()) { logger.log(INFO, "Deployment expired before tests could complete."); return Optional.of(aborted); } @@ -485,15 +488,22 @@ public class InternalStepRunner implements StepRunner { } } - Optional<URI> testerEndpoint = controller.jobController().testerEndpoint(id); - if ( ! testerEndpoint.isPresent()) { - logger.log("Endpoints for tester not found -- trying again later."); - return Optional.empty(); - } - controller.jobController().updateTestLog(id); - TesterCloud.Status testStatus = controller.jobController().cloud().getStatus(testerEndpoint.get()); + BooleanFlag useConfigServerForTesterAPI = Flags.USE_CONFIG_SERVER_FOR_TESTER_API_CALLS.bindTo(controller.flagSource()); + ZoneId zoneId = id.type().zone(controller.system()); + TesterCloud.Status testStatus; + if (useConfigServerForTesterAPI.with(FetchVector.Dimension.ZONE_ID, zoneId.value()).value()) { + testStatus = controller.serviceRegistry().configServer().getTesterStatus(new DeploymentId(id.application(), zoneId)); + } else { + Optional<URI> testerEndpoint = controller.jobController().testerEndpoint(id); + if (testerEndpoint.isEmpty()) { + logger.log("Endpoints for tester not found -- trying again later."); + return Optional.empty(); + } + testStatus = controller.jobController().cloud().getStatus(testerEndpoint.get()); + } + switch (testStatus) { case NOT_STARTED: throw new IllegalStateException("Tester reports tests not started, even though they should have!"); diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/integration/ConfigServerMock.java b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/integration/ConfigServerMock.java index b37d3d340cb..fef8ab32d17 100644 --- a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/integration/ConfigServerMock.java +++ b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/integration/ConfigServerMock.java @@ -27,6 +27,7 @@ import com.yahoo.vespa.hosted.controller.api.integration.configserver.Node; import com.yahoo.vespa.hosted.controller.api.integration.configserver.NotFoundException; import com.yahoo.vespa.hosted.controller.api.integration.configserver.PrepareResponse; import com.yahoo.vespa.hosted.controller.api.integration.configserver.ServiceConvergence; +import com.yahoo.vespa.hosted.controller.api.integration.deployment.TesterCloud; import com.yahoo.vespa.hosted.controller.application.ApplicationPackage; import com.yahoo.vespa.hosted.controller.application.SystemApplication; import com.yahoo.vespa.serviceview.bindings.ApplicationView; @@ -269,6 +270,11 @@ public class ConfigServerMock extends AbstractComponent implements ConfigServer return List.of(); } + @Override + public TesterCloud.Status getTesterStatus(DeploymentId deployment) { + return TesterCloud.Status.SUCCESS; + } + public void addLoadBalancers(ZoneId zone, List<LoadBalancer> loadBalancers) { this.loadBalancers.putIfAbsent(zone, new ArrayList<>()); this.loadBalancers.get(zone).addAll(loadBalancers); |