diff options
author | Morten Tokle <morten.tokle@gmail.com> | 2018-01-17 12:14:33 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-01-17 12:14:33 +0100 |
commit | ac0e0340fd7989ae4410aaf7e33eb2e1e848a88b (patch) | |
tree | 9cdb4fd678415b2f4ec36b98a154dfea4ff2268d /controller-server/src/main | |
parent | 024ff929534adef4f495e316457c2db5b8e8eca2 (diff) | |
parent | cf75d61771423f8c8f74fc3375b1930e5111597c (diff) |
Merge pull request #4687 from vespa-engine/mpolden/source-revision-in-job-report
Add source revision to job report
Diffstat (limited to 'controller-server/src/main')
5 files changed, 25 insertions, 22 deletions
diff --git a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/application/DeploymentJobs.java b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/application/DeploymentJobs.java index 1d04106d7bb..a728786e2ce 100644 --- a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/application/DeploymentJobs.java +++ b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/application/DeploymentJobs.java @@ -7,9 +7,9 @@ import com.yahoo.config.provision.ApplicationId; import com.yahoo.config.provision.Environment; import com.yahoo.config.provision.RegionName; import com.yahoo.config.provision.SystemName; -import com.yahoo.vespa.hosted.controller.api.integration.zone.ZoneId; import com.yahoo.vespa.hosted.controller.Controller; import com.yahoo.vespa.hosted.controller.api.integration.organization.IssueId; +import com.yahoo.vespa.hosted.controller.api.integration.zone.ZoneId; import java.time.Instant; import java.util.Collection; @@ -244,18 +244,21 @@ public class DeploymentJobs { private final JobType jobType; private final long projectId; private final long buildNumber; + private final Optional<SourceRevision> sourceRevision; private final Optional<JobError> jobError; public JobReport(ApplicationId applicationId, JobType jobType, long projectId, long buildNumber, - Optional<JobError> jobError) { + Optional<SourceRevision> sourceRevision, Optional<JobError> jobError) { Objects.requireNonNull(applicationId, "applicationId cannot be null"); Objects.requireNonNull(jobType, "jobType cannot be null"); + Objects.requireNonNull(sourceRevision, "sourceRevision cannot be null"); Objects.requireNonNull(jobError, "jobError cannot be null"); this.applicationId = applicationId; this.projectId = projectId; this.buildNumber = buildNumber; this.jobType = jobType; + this.sourceRevision = sourceRevision; // TODO: Require non-empty source revision if jobType == component this.jobError = jobError; } @@ -264,6 +267,7 @@ public class DeploymentJobs { public long projectId() { return projectId; } public long buildNumber() { return buildNumber; } public boolean success() { return ! jobError.isPresent(); } + public Optional<SourceRevision> sourceRevision() { return sourceRevision; } public Optional<JobError> jobError() { return jobError; } } diff --git a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/deployment/DeploymentOrder.java b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/deployment/DeploymentOrder.java index 25b3cd0fd1e..d506e8f3dcd 100644 --- a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/deployment/DeploymentOrder.java +++ b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/deployment/DeploymentOrder.java @@ -6,7 +6,6 @@ import com.yahoo.vespa.hosted.controller.Application; import com.yahoo.vespa.hosted.controller.Controller; import com.yahoo.vespa.hosted.controller.LockedApplication; import com.yahoo.vespa.hosted.controller.api.integration.zone.ZoneId; -import com.yahoo.vespa.hosted.controller.application.Change; import com.yahoo.vespa.hosted.controller.application.Deployment; import com.yahoo.vespa.hosted.controller.application.DeploymentJobs; import com.yahoo.vespa.hosted.controller.application.DeploymentJobs.JobType; @@ -116,12 +115,6 @@ public class DeploymentOrder { .collect(collectingAndThen(toList(), Collections::unmodifiableList)); } - /** Returns whether all jobs have completed successfully for given step */ - private boolean completedSuccessfully(DeploymentSpec.Step step, Change change, Application application) { - return jobsFrom(step).stream() - .allMatch(job -> application.deploymentJobs().isSuccessful(change, job)); - } - /** Resolve deployment step from job */ private Optional<DeploymentSpec.Step> fromJob(JobType job, Application application) { for (DeploymentSpec.Step step : application.deploymentSpec().steps()) { 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 08676a4d1b5..7908f9b095a 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 @@ -399,11 +399,11 @@ public class DeploymentTrigger { if ( ! job.isProduction()) throw new IllegalArgumentException(job + " is not a production job!"); - return lastSuccessfulIs(version, job, application) - || job.zone(controller.system()) - .map(zone -> application.deployments().get(zone)) - .map(deployment -> deployment.version().isAfter(version)) - .orElse(false); + return lastSuccessfulIs(version, job, application) || + job.zone(controller.system()) + .map(zone -> application.deployments().get(zone)) + .map(deployment -> deployment.version().isAfter(version)) + .orElse(false); } private boolean acceptNewRevisionNow(LockedApplication application) { diff --git a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/restapi/screwdriver/ScrewdriverApiHandler.java b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/restapi/screwdriver/ScrewdriverApiHandler.java index 17181950a29..44f3197643a 100644 --- a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/restapi/screwdriver/ScrewdriverApiHandler.java +++ b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/restapi/screwdriver/ScrewdriverApiHandler.java @@ -16,6 +16,7 @@ import com.yahoo.vespa.hosted.controller.api.integration.BuildService.BuildJob; import com.yahoo.vespa.hosted.controller.application.DeploymentJobs.JobError; import com.yahoo.vespa.hosted.controller.application.DeploymentJobs.JobReport; import com.yahoo.vespa.hosted.controller.application.DeploymentJobs.JobType; +import com.yahoo.vespa.hosted.controller.application.SourceRevision; import com.yahoo.vespa.hosted.controller.restapi.ErrorResponse; import com.yahoo.vespa.hosted.controller.restapi.Path; import com.yahoo.vespa.hosted.controller.restapi.SlimeJsonResponse; @@ -173,10 +174,21 @@ public class ScrewdriverApiHandler extends LoggingRequestHandler { JobType.fromJobName(report.field("jobName").asString()), report.field("projectId").asLong(), report.field("buildNumber").asLong(), + toSourceRevision(report.field("sourceRevision")), jobError ); } + private static Optional<SourceRevision> toSourceRevision(Inspector object) { + if (!object.field("repository").valid() || + !object.field("branch").valid() || + !object.field("commit").valid()) { + return Optional.empty(); + } + return Optional.of(new SourceRevision(object.field("repository").asString(), object.field("branch").asString(), + object.field("commit").asString())); + } + private static String asString(InputStream in) { Scanner scanner = new Scanner(in).useDelimiter("\\A"); if (scanner.hasNext()) { diff --git a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/versions/VersionStatus.java b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/versions/VersionStatus.java index 13eec52b97a..c1e23e91eac 100644 --- a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/versions/VersionStatus.java +++ b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/versions/VersionStatus.java @@ -5,13 +5,11 @@ import com.google.common.collect.ImmutableList; import com.yahoo.collections.ListMap; import com.yahoo.component.Version; import com.yahoo.component.Vtag; -import com.yahoo.config.provision.RegionName; import com.yahoo.vespa.hosted.controller.Application; import com.yahoo.vespa.hosted.controller.Controller; import com.yahoo.vespa.hosted.controller.api.integration.github.GitSha; import com.yahoo.vespa.hosted.controller.application.ApplicationList; import com.yahoo.vespa.hosted.controller.application.Deployment; -import com.yahoo.vespa.hosted.controller.application.DeploymentJobs; import com.yahoo.vespa.hosted.controller.application.JobList; import java.net.URI; @@ -95,8 +93,7 @@ public class VersionStatus { Version systemVersion = infrastructureVersions.stream().sorted().findFirst().get(); Collection<DeploymentStatistics> deploymentStatistics = computeDeploymentStatistics(infrastructureVersions, - controller.applications().asList(), - controller.applications().deploymentTrigger().jobTimeoutLimit()); + controller.applications().asList()); List<VespaVersion> versions = new ArrayList<>(); for (DeploymentStatistics statistics : deploymentStatistics) { @@ -132,8 +129,7 @@ public class VersionStatus { } private static Collection<DeploymentStatistics> computeDeploymentStatistics(Set<Version> infrastructureVersions, - List<Application> applications, - Instant jobTimeoutLimit) { + List<Application> applications) { Map<Version, DeploymentStatistics> versionMap = new HashMap<>(); for (Version infrastructureVersion : infrastructureVersions) { @@ -141,8 +137,6 @@ public class VersionStatus { } for (Application application : ApplicationList.from(applications).notPullRequest().asList()) { - DeploymentJobs jobs = application.deploymentJobs(); - // Note that each version deployed on this application in production exists // (ignore non-production versions) for (Deployment deployment : application.productionDeployments().values()) { |