diff options
author | Martin Polden <mpolden@mpolden.no> | 2020-01-09 14:14:57 +0100 |
---|---|---|
committer | Martin Polden <mpolden@mpolden.no> | 2020-01-09 14:14:57 +0100 |
commit | 7e2e34f77518970576a14e5d92fc362ee5487c70 (patch) | |
tree | a8fc2a03aa306e0ceb50a80d2c4a80c57d1997c8 | |
parent | bdade3d81383517b364c4e7034316e018ae536fd (diff) |
Read version status only once
2 files changed, 11 insertions, 4 deletions
diff --git a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/deployment/JobController.java b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/deployment/JobController.java index acfd326a5c0..28f8b1d201a 100644 --- a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/deployment/JobController.java +++ b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/deployment/JobController.java @@ -310,13 +310,17 @@ public class JobController { } /** Adds deployment status to each of the given applications. */ - public DeploymentStatusList deploymentStatuses(ApplicationList applications) { - var systemVersion = controller.systemVersion(); + public DeploymentStatusList deploymentStatuses(ApplicationList applications, Version systemVersion) { return DeploymentStatusList.from(applications.asList().stream() .map(application -> deploymentStatus(application, systemVersion)) .collect(toUnmodifiableList())); } + /** Adds deployment status to each of the given applications. Calling this will do an implicit read of the controller's version status */ + public DeploymentStatusList deploymentStatuses(ApplicationList applications) { + return deploymentStatuses(applications, controller.systemVersion()); + } + /** Changes the status of the given step, for the given run, provided it is still active. */ public void update(RunId id, RunStatus status, LockedStep step) { locked(id, run -> run.with(status, step)); diff --git a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/restapi/deployment/DeploymentApiHandler.java b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/restapi/deployment/DeploymentApiHandler.java index 1f1dcbb8001..600ad322f84 100644 --- a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/restapi/deployment/DeploymentApiHandler.java +++ b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/restapi/deployment/DeploymentApiHandler.java @@ -2,6 +2,7 @@ package com.yahoo.vespa.hosted.controller.restapi.deployment; import com.yahoo.component.Version; +import com.yahoo.component.Vtag; import com.yahoo.config.application.api.DeploymentInstanceSpec; import com.yahoo.config.application.api.DeploymentSpec; import com.yahoo.config.provision.ApplicationId; @@ -86,11 +87,13 @@ public class DeploymentApiHandler extends LoggingRequestHandler { Slime slime = new Slime(); Cursor root = slime.setObject(); Cursor platformArray = root.setArray("versions"); - Map<ApplicationId, JobList> jobs = controller.jobController().deploymentStatuses(ApplicationList.from(controller.applications().asList())) + var versionStatus = controller.versionStatus(); + var systemVersion = versionStatus.systemVersion().map(VespaVersion::versionNumber).orElse(Vtag.currentVersion); + Map<ApplicationId, JobList> jobs = controller.jobController().deploymentStatuses(ApplicationList.from(controller.applications().asList()), systemVersion) .asList().stream() .flatMap(status -> status.instanceJobs().entrySet().stream()) .collect(Collectors.toUnmodifiableMap(Map.Entry::getKey, Map.Entry::getValue)); - for (VespaVersion version : controller.versionStatus().versions()) { + for (VespaVersion version : versionStatus.versions()) { Cursor versionObject = platformArray.addObject(); versionObject.setString("version", version.versionNumber().toString()); versionObject.setString("confidence", version.confidence().name()); |