Log the time when job started failing
@@ -3,14 +3,12 @@ package com.yahoo.vespa.hosted.controller.maintenance;
import com.yahoo.vespa.hosted.controller.Application;
import com.yahoo.vespa.hosted.controller.Controller;
-import com.yahoo.vespa.hosted.controller.application.DeploymentJobs.JobType;
import com.yahoo.vespa.hosted.controller.application.JobStatus;
import java.time.Duration;
import java.time.Instant;
import java.util.Comparator;
import java.util.List;
-import java.util.Map;
import java.util.Optional;
/**
@@ -41,9 +39,9 @@ public class FailureRedeployer extends Maintainer {
if (application.deploymentJobs().inProgress()) {
continue;
}
- Optional<Map.Entry<JobType, JobStatus>> failingJob = jobFailingFor(application);
- failingJob.ifPresent(job -> triggerFailing(application, "Job " + job.getKey().id() +
- " has been failing since " + job.getValue().lastCompleted().get()));
+ Optional<JobStatus> failingJob = jobFailingFor(application);
+ failingJob.ifPresent(job -> triggerFailing(application, "Job " + job.type().id() +
+ " has been failing since " + job.firstFailing().get()));
}
}
@@ -53,31 +51,31 @@ public class FailureRedeployer extends Maintainer {
if (!application.deploying().isPresent()) {
continue;
}
- Optional<Map.Entry<JobType, JobStatus>> job = oldestRunningJob(application);
+ Optional<JobStatus> job = oldestRunningJob(application);
if (!job.isPresent()) {
continue;
}
// Ignore job if it doesn't belong to a zone in this system
- if (!job.get().getKey().zone(controller().system()).isPresent()) {
+ if (!job.get().type().zone(controller().system()).isPresent()) {
continue;
}
- if (job.get().getValue().lastTriggered().get().at().isBefore(maxAge)) {
- triggerFailing(application, "Job " + job.get().getKey().id() +
+ if (job.get().lastTriggered().get().at().isBefore(maxAge)) {
+ triggerFailing(application, "Job " + job.get().type().id() +
" has been running for more than " + jobTimeout);
}
}
}
- private Optional<Map.Entry<JobType, JobStatus>> jobFailingFor(Application application) {
- return application.deploymentJobs().jobStatus().entrySet().stream()
- .filter(e -> !e.getValue().isSuccess() && e.getValue().lastCompletedFor(application.deploying().get()))
+ private Optional<JobStatus> jobFailingFor(Application application) {
+ return application.deploymentJobs().jobStatus().values().stream()
+ .filter(status -> !status.isSuccess() && status.lastCompletedFor(application.deploying().get()))
.findFirst();
}
- private Optional<Map.Entry<JobType, JobStatus>> oldestRunningJob(Application application) {
- return application.deploymentJobs().jobStatus().entrySet().stream()
- .filter(kv -> kv.getValue().inProgress())
- .sorted(Comparator.comparing(kv -> kv.getValue().lastTriggered().get().at()))
+ private Optional<JobStatus> oldestRunningJob(Application application) {
+ return application.deploymentJobs().jobStatus().values().stream()
+ .filter(JobStatus::inProgress)
+ .sorted(Comparator.comparing(status -> status.lastTriggered().get().at()))
.findFirst();
}
