summaryrefslogtreecommitdiffstats
path: root/controller-server
diff options
context:
space:
mode:
authorjonmv <venstad@gmail.com>2023-01-03 09:59:08 +0100
committerjonmv <venstad@gmail.com>2023-01-03 09:59:08 +0100
commit5d094f89ee2f93b423888376bde1c20a4869e4e6 (patch)
treeb1bab6efb6881d6d3767fcffcd1fd4a19f4c370b /controller-server
parent470e303a873bece667965f6d20f2b6c5fa98e537 (diff)
Compute prerequisite tests for a given prod deployment
Diffstat (limited to 'controller-server')
-rw-r--r--controller-server/src/main/java/com/yahoo/vespa/hosted/controller/deployment/DeploymentStatus.java27
-rw-r--r--controller-server/src/main/java/com/yahoo/vespa/hosted/controller/deployment/DeploymentTrigger.java11
-rw-r--r--controller-server/src/main/java/com/yahoo/vespa/hosted/controller/deployment/Run.java1
3 files changed, 30 insertions, 9 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 ef4ee16217e..e90d6adc2f0 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
@@ -33,14 +33,15 @@ import com.yahoo.vespa.hosted.controller.versions.VespaVersion.Confidence;
import java.time.Duration;
import java.time.Instant;
import java.time.temporal.ChronoUnit;
+import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Collections;
+import java.util.Deque;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
-import java.util.Map.Entry;
import java.util.Objects;
import java.util.Optional;
import java.util.Set;
@@ -67,7 +68,6 @@ import static java.util.stream.Collectors.mapping;
import static java.util.stream.Collectors.toList;
import static java.util.stream.Collectors.toMap;
import static java.util.stream.Collectors.toSet;
-import static java.util.stream.Collectors.toUnmodifiableList;
/**
* Status of the deployment jobs of an {@link Application}.
@@ -444,7 +444,7 @@ public class DeploymentStatus {
* which does not downgrade any deployments in the instance,
* which is not already rolling out to the instance, and
* which causes at least one job to run if deployed to the instance.
- * For the "exclusive" revision upgrade policy it is the oldest such revision; otherwise, it is the latest.
+ * For the "next" revision target policy it is the oldest such revision; otherwise, it is the latest.
*/
public Change outstandingChange(InstanceName instance) {
StepStatus status = instanceSteps().get(instance);
@@ -749,6 +749,27 @@ public class DeploymentStatus {
return first;
}
+ /**
+ * Returns set of declared tests directly reachable from the given production job, or the first declared (or implicit) test.
+ * A test in instance {@code I} is directly reachable from a job in instance {@code K} if a chain of instances {@code I, J, ..., K}
+ * exists, such that only {@code I} has a declared test of the particular type.
+ * These are the declared tests that should be OK before we proceed with the corresponding production deployment.
+ * If no such tests exist, the first declared test, or a test in the first declared instance, is used instead.
+ */
+ private List<JobId> prerequisiteTests(JobId prodJob, JobType testType) {
+ List<JobId> tests = new ArrayList<>();
+ Deque<InstanceName> instances = new ArrayDeque<>();
+ instances.add(prodJob.application().instance());
+ while ( ! instances.isEmpty()) {
+ InstanceName instance = instances.poll();
+ Optional<JobId> test = declaredTest(application().id().instance(instance), testType);
+ if (test.isPresent()) tests.add(test.get());
+ else instances.addAll(instanceSteps().get(instance).dependencies().stream().map(StepStatus::instance).toList());
+ }
+ if (tests.isEmpty()) tests.add(firstDeclaredOrElseImplicitTest(testType));
+ return tests;
+ }
+
/** Adds the primitive steps contained in the given step, which depend on the given previous primitives, to the dependency graph. */
private List<StepStatus> fillStep(Map<JobId, StepStatus> dependencies, List<StepStatus> allSteps, DeploymentSpec.Step step,
List<StepStatus> previous, InstanceName instance, Function<JobId, JobStatus> 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 169cde8437a..e905b60687e 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
@@ -452,12 +452,11 @@ public class DeploymentTrigger {
Predicate<RevisionId> revisionFilter = spec.revisionTarget() == DeploymentSpec.RevisionTarget.next
? failing -> status.application().require(instance).change().revision().get().compareTo(failing) == 0
: failing -> revision.compareTo(failing) > 0;
- switch (spec.revisionChange()) {
- case whenClear: return ! isChangingRevision;
- case whenFailing: return ! isChangingRevision || status.hasFailures(revisionFilter);
- case always: return true;
- default: throw new IllegalStateException("Unknown revision upgrade policy");
- }
+ return switch (spec.revisionChange()) {
+ case whenClear -> ! isChangingRevision;
+ case whenFailing -> ! isChangingRevision || status.hasFailures(revisionFilter);
+ case always -> true;
+ };
}
private Instance withRemainingChange(Instance instance, Change change, DeploymentStatus status, boolean allowOutdatedPlatform) {
diff --git a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/deployment/Run.java b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/deployment/Run.java
index 7ffaaabb1a7..71ff28c47e6 100644
--- a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/deployment/Run.java
+++ b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/deployment/Run.java
@@ -14,6 +14,7 @@ import java.util.stream.Collectors;
import static com.yahoo.vespa.hosted.controller.deployment.RunStatus.aborted;
import static com.yahoo.vespa.hosted.controller.deployment.RunStatus.noTests;
+import static com.yahoo.vespa.hosted.controller.deployment.RunStatus.reset;
import static com.yahoo.vespa.hosted.controller.deployment.RunStatus.running;
import static com.yahoo.vespa.hosted.controller.deployment.RunStatus.success;
import static com.yahoo.vespa.hosted.controller.deployment.Step.Status.succeeded;