diff options
author | jonmv <venstad@gmail.com> | 2022-09-26 11:36:07 +0200 |
---|---|---|
committer | jonmv <venstad@gmail.com> | 2022-09-26 11:36:07 +0200 |
commit | 702597f2d08121b93e6768d221b84bf36b1834ce (patch) | |
tree | e157f931abfbf684fd3e85ed9892a263334637dc /controller-server | |
parent | 02f2add4405c0f92f1342097800121b013a19a42 (diff) |
Pick cloud used by app for manually triggered test jobs
Diffstat (limited to 'controller-server')
3 files changed, 9 insertions, 11 deletions
diff --git a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/deployment/DeploymentStatus.java b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/deployment/DeploymentStatus.java index 8b7df7932ff..ddf4dcda7e3 100644 --- a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/deployment/DeploymentStatus.java +++ b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/deployment/DeploymentStatus.java @@ -312,7 +312,7 @@ public class DeploymentStatus { * if no such deployments exist, all clouds the application deploy to, and their first production deployments; or * if no clouds are deployed to at all, the system default cloud. */ - Map<CloudName, Optional<JobId>> firstDependentProductionJobsWithDeployment(InstanceName testInstance) { + public Map<CloudName, Optional<JobId>> firstDependentProductionJobsWithDeployment(InstanceName testInstance) { // Find instances' dependencies on each other: these are topologically ordered, so a simple traversal does it. Map<InstanceName, Set<InstanceName>> dependencies = new HashMap<>(); instanceSteps().forEach((name, step) -> { diff --git a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/deployment/DeploymentTrigger.java b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/deployment/DeploymentTrigger.java index 9e107a52b55..cf09afa7181 100644 --- a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/deployment/DeploymentTrigger.java +++ b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/deployment/DeploymentTrigger.java @@ -4,6 +4,7 @@ package com.yahoo.vespa.hosted.controller.deployment; import com.yahoo.config.application.api.DeploymentInstanceSpec; import com.yahoo.config.application.api.DeploymentSpec; import com.yahoo.config.provision.ApplicationId; +import com.yahoo.config.provision.CloudName; import com.yahoo.config.provision.InstanceName; import com.yahoo.config.provision.TenantName; import com.yahoo.transaction.Mutex; @@ -199,11 +200,17 @@ public class DeploymentTrigger { boolean upgradeRevision, boolean upgradePlatform) { Application application = applications().requireApplication(TenantAndApplicationId.from(applicationId)); Instance instance = application.require(applicationId.instance()); + DeploymentStatus status = jobs.deploymentStatus(application); + if (jobType.environment().isTest()) { + CloudName cloud = status.firstDependentProductionJobsWithDeployment(applicationId.instance()).keySet().stream().findFirst() + .orElse(controller.zoneRegistry().systemZone().getCloudName()); + jobType = jobType.isSystemTest() ? JobType.systemTest(controller.zoneRegistry(), cloud) + : JobType.stagingTest(controller.zoneRegistry(), cloud); + } JobId job = new JobId(instance.id(), jobType); if (job.type().environment().isManuallyDeployed()) return forceTriggerManualJob(job, reason); - DeploymentStatus status = jobs.deploymentStatus(application); Change change = instance.change(); if ( ! upgradeRevision && change.revision().isPresent()) change = change.withoutApplication(); if ( ! upgradePlatform && change.platform().isPresent()) change = change.withoutPlatform(); diff --git a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/restapi/application/ApplicationApiHandler.java b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/restapi/application/ApplicationApiHandler.java index 10bf0d2aa4f..e8fe7b7d5f0 100644 --- a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/restapi/application/ApplicationApiHandler.java +++ b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/restapi/application/ApplicationApiHandler.java @@ -1471,15 +1471,6 @@ public class ApplicationApiHandler extends AuditLoggingRequestHandler { private HttpResponse trigger(ApplicationId id, JobType type, HttpRequest request) { - // JobType.fromJobName doesn't properly initiate test jobs. Triggering these without context isn't _really_ - // necessary, but triggering a test in the default cloud is better than failing with a weird error. - ZoneRegistry zones = controller.zoneRegistry(); - type = switch (type.environment()) { - case test -> JobType.systemTest(zones, zones.systemZone().getCloudName()); - case staging -> JobType.stagingTest(zones, zones.systemZone().getCloudName()); - default -> type; - }; - Inspector requestObject = toSlime(request.getData()).get(); boolean requireTests = ! requestObject.field("skipTests").asBool(); boolean reTrigger = requestObject.field("reTrigger").asBool(); |