diff options
author | Jon Bratseth <bratseth@yahoo-inc.com> | 2017-10-10 16:39:50 +0200 |
---|---|---|
committer | Jon Bratseth <bratseth@yahoo-inc.com> | 2017-10-10 16:39:50 +0200 |
commit | 20fa3ded612896a4ed2b8bc20d6151f86b1dab19 (patch) | |
tree | c7641299a15e2d9b559296cb7f1161e1a6f717c4 /controller-server/src | |
parent | d08187b6db28cbc5fec544edd1fcf61630169cc7 (diff) |
Use isRunning
Diffstat (limited to 'controller-server/src')
3 files changed, 11 insertions, 11 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 26cf44002ff..1ffa06bb624 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 @@ -101,8 +101,15 @@ public class DeploymentJobs { } /** Returns whether any job is currently in progress */ - public boolean inProgress() { - return status.values().stream().anyMatch(JobStatus::inProgress); + public boolean isRunning(Instant timeoutLimit) { + return status.values().stream().anyMatch(job -> job.isRunning(timeoutLimit)); + } + + /** Returns whether the given job type is currently running and was started after timeoutLimit */ + public boolean isRunning(JobType jobType, Instant timeoutLimit) { + JobStatus jobStatus = status.get(jobType); + if ( jobStatus == null) return false; + return jobStatus.isRunning(timeoutLimit); } /** Returns whether change can be deployed to the given environment */ @@ -310,11 +317,4 @@ public class DeploymentJobs { return id; } - /** Returns whether the given job type is currently running and was started after timeoutLimit */ - public boolean isRunning(JobType jobType, Instant timeoutLimit) { - JobStatus jobStatus = status.get(jobType); - if ( jobStatus == null) return false; - return jobStatus.isRunning(timeoutLimit); - } - }
\ No newline at end of file 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 d7a1d70787f..9db7ac357f2 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 @@ -198,7 +198,7 @@ public class DeploymentTrigger { for (Application application : applications().asList()) { if ( ! application.deploying().isPresent() ) continue; if (application.deploymentJobs().hasFailures()) continue; - if (application.deploymentJobs().inProgress()) continue; + if (application.deploymentJobs().isRunning(controller.applications().deploymentTrigger().jobTimeoutLimit())) continue; if (application.deploymentSpec().steps().stream().noneMatch(step -> step instanceof DeploymentSpec.Delay)) { continue; // Application does not have any delayed deployments } diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/maintenance/UpgraderTest.java b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/maintenance/UpgraderTest.java index ea17b49cc69..30a2cf505a0 100644 --- a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/maintenance/UpgraderTest.java +++ b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/maintenance/UpgraderTest.java @@ -449,7 +449,7 @@ public class UpgraderTest { // 5th app never reports back and has a dead job, but no ongoing change Application deadLocked = tester.applications().require(default4.id()); - assertTrue("Jobs in progress", deadLocked.deploymentJobs().inProgress()); + assertTrue("Jobs in progress", deadLocked.deploymentJobs().isRunning(tester.controller().applications().deploymentTrigger().jobTimeoutLimit())); assertFalse("No change present", deadLocked.deploying().isPresent()); // 4/5 applications are repaired and confidence is restored |