summaryrefslogtreecommitdiffstats
path: root/controller-server
diff options
context:
space:
mode:
authorJon Marius Venstad <venstad@gmail.com>2022-03-07 21:22:48 +0100
committerJon Marius Venstad <venstad@gmail.com>2022-03-07 21:22:48 +0100
commite80bdf0665c29b8e7e5fc8753ea9dd10f4b08d50 (patch)
treecf80421138c1c4edcdb1e9a8ec163fe13e907772 /controller-server
parentb0570dbddebc7c618924f1728a9cb15b8cd17a44 (diff)
Facilitate debugging with less functional style
Diffstat (limited to 'controller-server')
-rw-r--r--controller-server/src/main/java/com/yahoo/vespa/hosted/controller/deployment/DeploymentStatus.java23
1 files changed, 12 insertions, 11 deletions
diff --git a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/deployment/DeploymentStatus.java b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/deployment/DeploymentStatus.java
index f84a1ecd7f5..b3005062e1d 100644
--- a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/deployment/DeploymentStatus.java
+++ b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/deployment/DeploymentStatus.java
@@ -43,7 +43,6 @@ import static com.yahoo.config.provision.Environment.staging;
import static com.yahoo.config.provision.Environment.test;
import static com.yahoo.vespa.hosted.controller.api.integration.deployment.JobType.stagingTest;
import static com.yahoo.vespa.hosted.controller.api.integration.deployment.JobType.systemTest;
-import static java.util.Collections.reverseOrder;
import static java.util.Comparator.comparing;
import static java.util.Comparator.naturalOrder;
import static java.util.Objects.requireNonNull;
@@ -265,16 +264,18 @@ public class DeploymentStatus {
* For the "exclusive" revision upgrade policy it is the oldest such revision; otherwise, it is the latest.
*/
public Change outstandingChange(InstanceName instance) {
- return Optional.ofNullable(instanceSteps().get(instance))
- .flatMap(instanceStatus -> application.deployableVersions(application.deploymentSpec().requireInstance(instance).revisionTarget() == next).stream()
- .filter(version -> instanceStatus.dependenciesCompletedAt(Change.of(version), Optional.empty()).map(at -> ! at.isAfter(now)).orElse(false))
- .filter(version -> application.productionDeployments().getOrDefault(instance, List.of()).stream()
- .noneMatch(deployment -> deployment.applicationVersion().compareTo(version) > 0))
- .map(Change::of)
- .filter(change -> application.require(instance).change().application().map(change::upgrades).orElse(true))
- .filter(change -> ! hasCompleted(instance, change))
- .findFirst())
- .orElse(Change.empty());
+ StepStatus status = instanceSteps().get(instance);
+ if (status == null) return Change.empty();
+ for (ApplicationVersion version : application.deployableVersions(application.deploymentSpec().requireInstance(instance).revisionTarget() == next)) {
+ if (status.dependenciesCompletedAt(Change.of(version), Optional.empty()).map(now::isBefore).orElse(true)) continue;
+ Change change = Change.of(version);
+ if (application.productionDeployments().getOrDefault(instance, List.of()).stream()
+ .anyMatch(deployment -> change.downgrades(deployment.applicationVersion()))) continue;
+ if ( ! application.require(instance).change().application().map(change::upgrades).orElse(true)) continue;
+ if (hasCompleted(instance, change)) continue;
+ return change;
+ }
+ return Change.empty();
}
/** Earliest instant when job was triggered with given versions, or both system and staging tests were successful. */