diff options
author | Jon Marius Venstad <jvenstad@yahoo-inc.com> | 2018-10-31 16:01:25 +0100 |
---|---|---|
committer | Jon Marius Venstad <jvenstad@yahoo-inc.com> | 2018-10-31 16:01:25 +0100 |
commit | 792680b72dd63de4619e13abe70935c1bb695e69 (patch) | |
tree | 7dd48e37d81d82f6db6af1f87f1bab71334338e6 /controller-server | |
parent | 395b92078098ca3a735dfbe33aee9a0dab9cce8b (diff) |
Replace changeAt(instance) with just change()
Diffstat (limited to 'controller-server')
5 files changed, 10 insertions, 29 deletions
diff --git a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/Application.java b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/Application.java index cd063e8e14b..0c33307bf80 100644 --- a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/Application.java +++ b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/Application.java @@ -129,24 +129,6 @@ public class Application { public Change change() { return change; } /** - * Returns the target that should be used for this application at the given instant, typically now. - * - * This will be any parts of current total change that aren't both blocked and not yet deployed anywhere. - */ - public Change changeAt(Instant now) { - Change change = this.change; - if ( this.change.platform().isPresent() - && productionDeployments().values().stream().noneMatch(deployment -> deployment.version().equals(this.change.platform().get())) - && ! deploymentSpec.canUpgradeAt(now)) - change = change.withoutPlatform(); - if ( this.change.application().isPresent() - && productionDeployments().values().stream().noneMatch(deployment -> deployment.applicationVersion().equals(this.change.application().get())) - && ! deploymentSpec.canChangeRevisionAt(now)) - change = change.withoutApplication(); - return change; - } - - /** * Returns whether this has an outstanding change (in the source repository), which * has currently not started deploying (because a deployment is (or was) already in progress */ diff --git a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/application/ApplicationList.java b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/application/ApplicationList.java index 2ee0ee960a2..e6e1bfd9c14 100644 --- a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/application/ApplicationList.java +++ b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/application/ApplicationList.java @@ -82,9 +82,9 @@ public class ApplicationList { return listOf(list.stream().filter(application -> application.change().isPresent() || application.outstandingChange().isPresent())); } - /** Returns the subset of applications which are currently really not deploying a change */ - public ApplicationList notDeployingAt(Instant now) { - return listOf(list.stream().filter(application -> ! application.changeAt(now).isPresent())); + /** Returns the subset of applications which are currently not deploying a change */ + public ApplicationList notDeploying() { + return listOf(list.stream().filter(application -> ! application.change().isPresent())); } /** Returns the subset of applications which currently does not have any failing jobs */ 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 dc6930e2312..cbd241e5df0 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 @@ -230,7 +230,7 @@ public class DeploymentTrigger { */ public void triggerChange(ApplicationId applicationId, Change change) { applications().lockOrThrow(applicationId, application -> { - if (application.get().changeAt(controller.clock().instant()).isPresent() && ! application.get().deploymentJobs().hasFailures()) + if (application.get().change().isPresent() && ! application.get().deploymentJobs().hasFailures()) throw new IllegalArgumentException("Could not start " + change + " on " + application + ": " + application.get().change() + " is already in progress"); application = application.withChange(change); @@ -289,7 +289,7 @@ public class DeploymentTrigger { private List<Job> computeReadyJobs(ApplicationId id) { List<Job> jobs = new ArrayList<>(); applications().get(id).ifPresent(application -> { - Change change = application.changeAt(clock.instant()); + Change change = application.change(); Optional<Instant> completedAt = max(application.deploymentJobs().statusOf(systemTest) .<Instant>flatMap(job -> job.lastSuccess().map(JobRun::at)), application.deploymentJobs().statusOf(stagingTest) @@ -492,7 +492,7 @@ public class DeploymentTrigger { if ( ! application.deploymentSpec().canChangeRevisionAt(clock.instant())) return false; if (application.change().application().isPresent()) return true; // Replacing a previous application change is ok. if (application.deploymentJobs().hasFailures()) return true; // Allow changes to fix upgrade problems. - return ! application.changeAt(clock.instant()).platform().isPresent(); + return ! application.change().platform().isPresent(); } private Change remainingChange(Application application) { diff --git a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/maintenance/Upgrader.java b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/maintenance/Upgrader.java index 06712ad7862..702df58ab98 100644 --- a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/maintenance/Upgrader.java +++ b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/maintenance/Upgrader.java @@ -95,7 +95,7 @@ public class Upgrader extends Maintainer { applications = applications.hasProductionDeployment(); applications = applications.onLowerVersionThan(version); applications = applications.allowMajorVersion(version.getMajor()); - applications = applications.notDeployingAt(controller().clock().instant()); // wait with applications deploying an application change or already upgrading + applications = applications.notDeploying(); // wait with applications deploying an application change or already upgrading applications = applications.notFailingOn(version); // try to upgrade only if it hasn't failed on this version applications = applications.canUpgradeAt(controller().clock().instant()); // wait with applications that are currently blocking upgrades applications = applications.byIncreasingDeployedVersion(); // start with lowest versions diff --git a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/restapi/application/JobControllerApiHandlerHelper.java b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/restapi/application/JobControllerApiHandlerHelper.java index 2e67f4b2efc..0d02c4003e7 100644 --- a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/restapi/application/JobControllerApiHandlerHelper.java +++ b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/restapi/application/JobControllerApiHandlerHelper.java @@ -28,7 +28,6 @@ import com.yahoo.vespa.hosted.controller.deployment.Run; import com.yahoo.vespa.hosted.controller.deployment.Step; import com.yahoo.vespa.hosted.controller.deployment.Versions; import com.yahoo.vespa.hosted.controller.restapi.SlimeJsonResponse; -import com.yahoo.vespa.hosted.controller.restapi.StringResponse; import com.yahoo.vespa.hosted.controller.versions.VespaVersion; import java.net.URI; @@ -68,7 +67,7 @@ class JobControllerApiHandlerHelper { */ static HttpResponse jobTypeResponse(Controller controller, ApplicationId id, URI baseUriForJobs) { Application application = controller.applications().require(id); - Change change = application.changeAt(controller.clock().instant()); + Change change = application.change(); DeploymentSteps steps = new DeploymentSteps(application.deploymentSpec(), controller::system); // The logic for pending runs imitates DeploymentTrigger logic; not good, but the trigger wiring must be re-written to reuse :S @@ -160,7 +159,7 @@ class JobControllerApiHandlerHelper { } else lastPlatformObject.setString("pending", - application.changeAt(controller.clock().instant()).isPresent() + application.change().isPresent() ? "Waiting for current deployment to complete" : "Waiting for upgrade slot"); } @@ -259,7 +258,7 @@ class JobControllerApiHandlerHelper { break; for (JobType stepType : steps.toJobs(step)) { if (pendingProduction.containsKey(stepType)) { - Versions jobVersions = Versions.from(application.changeAt(controller.clock().instant()), + Versions jobVersions = Versions.from(application.change(), application, Optional.ofNullable(application.deployments().get(stepType.zone(controller.system()))), controller.systemVersion()); |