Search in sources :

Example 6 with JobType

use of com.yahoo.vespa.hosted.controller.application.DeploymentJobs.JobType in project vespa by vespa-engine.

the class DeploymentTrigger method triggerReadyJobs.

// --- End of methods which triggers deployment jobs ----------------------------
/**
 * Find the next step to trigger if any, and triggers it
 */
private void triggerReadyJobs(LockedApplication application) {
    List<JobType> jobs = order.jobsFrom(application.deploymentSpec());
    // Should the first step be triggered?
    if (!jobs.isEmpty() && jobs.get(0).equals(JobType.systemTest)) {
        JobStatus systemTestStatus = application.deploymentJobs().jobStatus().get(JobType.systemTest);
        if (application.change().platform().isPresent()) {
            Version target = application.change().platform().get();
            if (systemTestStatus == null || !systemTestStatus.lastTriggered().isPresent() || !systemTestStatus.isSuccess() || !systemTestStatus.lastTriggered().get().version().equals(target) || systemTestStatus.isHanging(jobTimeoutLimit())) {
                application = trigger(new Triggering(application, JobType.systemTest, false, "Upgrade to " + target), Collections.emptySet(), false);
                applications().store(application);
            }
        }
    }
    // Find next steps to trigger based on the state of the previous step
    for (JobType jobType : (Iterable<JobType>) Stream.concat(Stream.of(JobType.component), jobs.stream())::iterator) {
        JobStatus jobStatus = application.deploymentJobs().jobStatus().get(jobType);
        // job has never run
        if (jobStatus == null)
            continue;
        // Collect the subset of next jobs which have not run with the last changes
        // TODO jvenstad: Change to be step-centric.
        List<JobType> nextJobs = order.nextAfter(jobType, application);
        for (JobType nextJobType : nextJobs) {
            JobStatus nextStatus = application.deploymentJobs().jobStatus().get(nextJobType);
            if (changesAvailable(application, jobStatus, nextStatus) || nextStatus.isHanging(jobTimeoutLimit())) {
                boolean isRetry = nextStatus != null && nextStatus.jobError().filter(JobError.outOfCapacity::equals).isPresent();
                application = trigger(new Triggering(application, nextJobType, isRetry, isRetry ? "Retrying on out of capacity" : "Available change in " + jobType.jobName()), nextJobs, false);
            }
        }
        applications().store(application);
    }
}
Also used : JobStatus(com.yahoo.vespa.hosted.controller.application.JobStatus) JobType(com.yahoo.vespa.hosted.controller.application.DeploymentJobs.JobType) Version(com.yahoo.component.Version) ApplicationVersion(com.yahoo.vespa.hosted.controller.application.ApplicationVersion)

Aggregations

JobType (com.yahoo.vespa.hosted.controller.application.DeploymentJobs.JobType)6 Version (com.yahoo.component.Version)4 ApplicationId (com.yahoo.config.provision.ApplicationId)4 BuildService (com.yahoo.vespa.hosted.controller.api.integration.BuildService)3 ApplicationVersion (com.yahoo.vespa.hosted.controller.application.ApplicationVersion)3 Change (com.yahoo.vespa.hosted.controller.application.Change)3 JobStatus (com.yahoo.vespa.hosted.controller.application.JobStatus)3 Duration (java.time.Duration)3 List (java.util.List)3 Optional (java.util.Optional)3 Environment (com.yahoo.config.provision.Environment)2 SystemName (com.yahoo.config.provision.SystemName)2 Application (com.yahoo.vespa.hosted.controller.Application)2 ApplicationController (com.yahoo.vespa.hosted.controller.ApplicationController)2 Controller (com.yahoo.vespa.hosted.controller.Controller)2 TenantId (com.yahoo.vespa.hosted.controller.api.identifiers.TenantId)2 ApplicationPackage (com.yahoo.vespa.hosted.controller.application.ApplicationPackage)2 Deployment (com.yahoo.vespa.hosted.controller.application.Deployment)2 DeploymentJobs (com.yahoo.vespa.hosted.controller.application.DeploymentJobs)2 JobError (com.yahoo.vespa.hosted.controller.application.DeploymentJobs.JobError)2