summaryrefslogtreecommitdiffstats
path: root/controller-server/src
diff options
context:
space:
mode:
authorJon Marius Venstad <jvenstad@yahoo-inc.com>2018-11-15 16:07:57 +0100
committerJon Marius Venstad <jvenstad@yahoo-inc.com>2018-11-15 16:07:57 +0100
commit275c26827bedd74c25a704e2e9dad5483e125afe (patch)
treec08b99a2eaef8137b08f843d69963be8f15f8d15 /controller-server/src
parent8ece4a3e82807740081aa64ed620a4fc879696bb (diff)
Add method to check node repo for oldest installed version, for compile version
Diffstat (limited to 'controller-server/src')
-rw-r--r--controller-server/src/main/java/com/yahoo/vespa/hosted/controller/Application.java5
-rw-r--r--controller-server/src/main/java/com/yahoo/vespa/hosted/controller/ApplicationController.java16
-rw-r--r--controller-server/src/main/java/com/yahoo/vespa/hosted/controller/deployment/DeploymentTrigger.java2
-rw-r--r--controller-server/src/main/java/com/yahoo/vespa/hosted/controller/restapi/application/ApplicationApiHandler.java2
4 files changed, 23 insertions, 2 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 2705debf8ba..619f8abc180 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
@@ -151,6 +151,11 @@ public class Application {
/**
* Returns the oldest platform version this has deployed in a permanent zone (not test or staging).
+ *
+ * This is unfortunately quite similar to {@link ApplicationController#oldestInstalledPlatform(ApplicationId)},
+ * but this checks only what the controller has deployed to the production zones, while that checks the node repository
+ * to see what's actually installed on each node. Thus, this is the right choice for, e.g., target Vespa versions for
+ * new deployments, while that is the right choice for version to compile against.
*/
public Optional<Version> oldestDeployedPlatform() {
return productionDeployments().values().stream()
diff --git a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/ApplicationController.java b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/ApplicationController.java
index 49bca3d51b7..953a226d089 100644
--- a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/ApplicationController.java
+++ b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/ApplicationController.java
@@ -25,6 +25,7 @@ import com.yahoo.vespa.hosted.controller.api.integration.configserver.ConfigServ
import com.yahoo.vespa.hosted.controller.api.integration.configserver.ConfigServerException;
import com.yahoo.vespa.hosted.controller.api.integration.configserver.Log;
import com.yahoo.vespa.hosted.controller.api.integration.configserver.NoInstanceException;
+import com.yahoo.vespa.hosted.controller.api.integration.configserver.Node;
import com.yahoo.vespa.hosted.controller.api.integration.configserver.PrepareResponse;
import com.yahoo.vespa.hosted.controller.api.integration.deployment.ApplicationStore;
import com.yahoo.vespa.hosted.controller.api.integration.deployment.ArtifactRepository;
@@ -67,6 +68,7 @@ import java.time.Instant;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
+import java.util.EnumSet;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
@@ -79,6 +81,10 @@ import java.util.logging.Level;
import java.util.logging.Logger;
import java.util.stream.Collectors;
+import static com.yahoo.vespa.hosted.controller.api.integration.configserver.Node.State.active;
+import static com.yahoo.vespa.hosted.controller.api.integration.configserver.Node.State.reserved;
+import static java.util.Comparator.naturalOrder;
+
/**
* A singleton owned by the Controller which contains the methods and state for controlling applications.
*
@@ -164,6 +170,16 @@ public class ApplicationController {
public ApplicationStore applicationStore() { return applicationStore; }
+ /** Returns the oldest Vespa version installed on any active or reserved production node for the given application. */
+ public Version oldestInstalledPlatform(ApplicationId id) {
+ return get(id).flatMap(application -> application.productionDeployments().keySet().stream()
+ .flatMap(zone -> configServer().nodeRepository().list(zone, id, EnumSet.of(active, reserved)).stream())
+ .map(Node::currentVersion)
+ .filter(version -> ! version.isEmpty())
+ .min(naturalOrder()))
+ .orElse(controller.systemVersion());
+ }
+
/**
* Set the rotations marked as 'global' either 'in' or 'out of' service.
*
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 d6182611fd5..8d3e1e9fffe 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
@@ -107,7 +107,7 @@ public class DeploymentTrigger {
JobRun triggering;
if (report.jobType() == component) {
ApplicationVersion applicationVersion = ApplicationVersion.from(report.sourceRevision().get(), report.buildNumber());
- triggering = JobRun.triggering(application.get().oldestDeployedPlatform().orElse(controller.systemVersion()), applicationVersion,
+ triggering = JobRun.triggering(applications().oldestInstalledPlatform(report.applicationId()), applicationVersion,
Optional.empty(), Optional.empty(), "Application commit", clock.instant());
if (report.success()) {
if (acceptNewApplicationVersion(application.get())) {
diff --git a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/restapi/application/ApplicationApiHandler.java b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/restapi/application/ApplicationApiHandler.java
index 3a83ecfb9e2..b3cba4809f0 100644
--- a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/restapi/application/ApplicationApiHandler.java
+++ b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/restapi/application/ApplicationApiHandler.java
@@ -443,7 +443,7 @@ public class ApplicationApiHandler extends LoggingRequestHandler {
});
// Compile version. The version that should be used when building an application
- object.setString("compileVersion", application.oldestDeployedPlatform().orElse(controller.systemVersion()).toFullString());
+ object.setString("compileVersion", controller.applications().oldestInstalledPlatform(application.id()).toFullString());
// Rotation
Cursor globalRotationsArray = object.setArray("globalRotations");