aboutsummaryrefslogtreecommitdiffstats
path: root/controller-server
diff options
context:
space:
mode:
authorjonmv <venstad@gmail.com>2022-09-07 15:31:18 +0200
committerjonmv <venstad@gmail.com>2022-09-12 15:14:05 +0200
commit9668e30a605a8e1ffb8a3c0c01aa55877ba81391 (patch)
treec30951ec54cafc38a4d6611d52e6627a6ac6e4d2 /controller-server
parentb444a4c3c56be61bd93c968e6891340a3feedeb3 (diff)
Consider version confidence for fallback platforms (when no deployments/change)
Diffstat (limited to 'controller-server')
-rw-r--r--controller-server/src/main/java/com/yahoo/vespa/hosted/controller/deployment/DeploymentStatus.java23
-rw-r--r--controller-server/src/main/java/com/yahoo/vespa/hosted/controller/deployment/JobController.java13
-rw-r--r--controller-server/src/main/java/com/yahoo/vespa/hosted/controller/deployment/Versions.java8
-rw-r--r--controller-server/src/test/java/com/yahoo/vespa/hosted/controller/deployment/DeploymentTriggerTest.java46
4 files changed, 75 insertions, 15 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 d96384946f7..fe216ea66e6 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
@@ -8,6 +8,7 @@ import com.yahoo.config.application.api.DeploymentInstanceSpec;
import com.yahoo.config.application.api.DeploymentSpec;
import com.yahoo.config.application.api.DeploymentSpec.DeclaredTest;
import com.yahoo.config.application.api.DeploymentSpec.DeclaredZone;
+import com.yahoo.config.application.api.DeploymentSpec.UpgradePolicy;
import com.yahoo.config.application.api.DeploymentSpec.UpgradeRollout;
import com.yahoo.config.provision.ApplicationId;
import com.yahoo.config.provision.CloudName;
@@ -314,13 +315,23 @@ public class DeploymentStatus {
/** Fall back to the newest, deployable platform, which is compatible with what we want to deploy. */
public Version fallbackPlatform(Change change, JobId job) {
+ InstanceName instance = job.application().instance();
Optional<Version> compileVersion = change.revision().map(application.revisions()::get).flatMap(ApplicationVersion::compileVersion);
- if (compileVersion.isEmpty())
- return systemVersion;
-
- for (VespaVersion version : reversed(versionStatus.deployableVersions()))
- if (versionCompatibility.apply(job.application().instance()).accept(version.versionNumber(), compileVersion.get()))
- return version.versionNumber();
+ List<Version> targets = targetsForPolicy(versionStatus,
+ systemVersion,
+ application.deploymentSpec().instance(instance)
+ .map(DeploymentInstanceSpec::upgradePolicy)
+ .orElse(UpgradePolicy.defaultPolicy));
+
+ // Prefer fallback with proper confidence.
+ for (Version target : targets)
+ if (compileVersion.isEmpty() || versionCompatibility.apply(instance).accept(target, compileVersion.get()))
+ return target;
+
+ // Try fallback with any confidence.
+ for (VespaVersion target : reversed(versionStatus.deployableVersions()))
+ if (compileVersion.isEmpty() || versionCompatibility.apply(instance).accept(target.versionNumber(), compileVersion.get()))
+ return target.versionNumber();
throw new IllegalArgumentException("no legal platform version exists in this system for compile version " + compileVersion.get());
}
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 9a84cd7304d..12ea322113f 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
@@ -5,6 +5,7 @@ import com.google.common.collect.ImmutableSortedMap;
import com.yahoo.component.Version;
import com.yahoo.component.VersionCompatibility;
import com.yahoo.concurrent.UncheckedTimeoutException;
+import com.yahoo.config.application.api.DeploymentSpec.UpgradePolicy;
import com.yahoo.config.provision.ApplicationId;
import com.yahoo.config.provision.SystemName;
import com.yahoo.config.provision.zone.ZoneId;
@@ -38,6 +39,7 @@ import com.yahoo.vespa.hosted.controller.persistence.BufferedLogStore;
import com.yahoo.vespa.hosted.controller.persistence.CuratorDb;
import com.yahoo.vespa.hosted.controller.versions.VersionStatus;
import com.yahoo.vespa.hosted.controller.versions.VespaVersion;
+import com.yahoo.vespa.hosted.controller.versions.VespaVersion.Confidence;
import java.io.IOException;
import java.io.InputStream;
@@ -754,9 +756,14 @@ public class JobController {
private Version findTargetPlatform(ApplicationPackage applicationPackage, DeploymentId id, Optional<Instance> instance) {
// Prefer previous platform if possible. Candidates are all deployable, ascending, with existing version appended; then reversed.
- List<Version> versions = controller.readVersionStatus().deployableVersions().stream()
- .map(VespaVersion::versionNumber)
- .collect(toList());
+ VersionStatus versionStatus = controller.readVersionStatus();
+ Version systemVersion = controller.systemVersion(versionStatus);
+
+ List<Version> versions = new ArrayList<>(List.of(systemVersion));
+ for (VespaVersion version : versionStatus.deployableVersions())
+ if (version.confidence().equalOrHigherThan(Confidence.low))
+ versions.add(version.versionNumber());
+
instance.map(Instance::deployments)
.map(deployments -> deployments.get(id.zoneId()))
.map(Deployment::version)
diff --git a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/deployment/Versions.java b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/deployment/Versions.java
index d683f1cb5c7..a172671fc8e 100644
--- a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/deployment/Versions.java
+++ b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/deployment/Versions.java
@@ -119,12 +119,8 @@ public class Versions {
}
/** Create versions using given change and application */
- public static Versions from(Change change, Application application, Optional<Deployment> deployment,
- Version defaultPlatformVersion) {
- return new Versions(targetPlatform(application, change, deployment.map(Deployment::version), defaultPlatformVersion),
- targetRevision(application, change, deployment.map(Deployment::revision)),
- deployment.map(Deployment::version),
- deployment.map(Deployment::revision));
+ public static Versions from(Change change, Application application, Optional<Deployment> deployment, Version defaultPlatformVersion) {
+ return from(change, application, deployment.map(Deployment::version), deployment.map(Deployment::revision), defaultPlatformVersion);
}
private static Version targetPlatform(Application application, Change change, Optional<Version> existing,
diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/deployment/DeploymentTriggerTest.java b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/deployment/DeploymentTriggerTest.java
index c18b333a91b..9daf8da4467 100644
--- a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/deployment/DeploymentTriggerTest.java
+++ b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/deployment/DeploymentTriggerTest.java
@@ -24,6 +24,7 @@ import com.yahoo.vespa.hosted.controller.application.SystemApplication;
import com.yahoo.vespa.hosted.controller.application.pkg.ApplicationPackage;
import com.yahoo.vespa.hosted.controller.integration.ZoneApiMock;
import com.yahoo.vespa.hosted.controller.integration.ZoneRegistryMock;
+import com.yahoo.vespa.hosted.controller.maintenance.DeploymentUpgrader;
import com.yahoo.vespa.hosted.controller.versions.VespaVersion;
import com.yahoo.vespa.hosted.controller.versions.VespaVersion.Confidence;
import org.junit.jupiter.api.Test;
@@ -62,6 +63,7 @@ import static com.yahoo.vespa.hosted.controller.deployment.DeploymentContext.tes
import static com.yahoo.vespa.hosted.controller.deployment.DeploymentContext.testUsWest1;
import static com.yahoo.vespa.hosted.controller.deployment.DeploymentTrigger.ChangesToCancel.ALL;
import static com.yahoo.vespa.hosted.controller.deployment.DeploymentTrigger.ChangesToCancel.PLATFORM;
+import static java.util.Collections.copy;
import static java.util.Collections.emptyList;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
@@ -2278,6 +2280,50 @@ public class DeploymentTriggerTest {
}
@Test
+ void testInitialDeploymentPlatform() {
+ Version version0 = tester.controllerTester().controller().readSystemVersion();
+ Version version1 = new Version("6.2");
+ Version version2 = new Version("6.3");
+ assertEquals(version0, tester.newDeploymentContext("t", "a1", "default").submit().deploy().application().oldestDeployedPlatform().get());
+
+ tester.controllerTester().upgradeSystem(version1);
+ tester.upgrader().overrideConfidence(version1, Confidence.normal);
+ tester.controllerTester().computeVersionStatus();
+ assertEquals(version1, tester.newDeploymentContext("t", "a2", "default").submit().deploy().application().oldestDeployedPlatform().get());
+
+ tester.controllerTester().upgradeSystem(version2);
+ tester.upgrader().overrideConfidence(version2, Confidence.broken);
+ tester.controllerTester().computeVersionStatus();
+ assertEquals(version1, tester.newDeploymentContext("t", "a3", "default").submit().deploy().application().oldestDeployedPlatform().get());
+
+ DeploymentContext dev1 = tester.newDeploymentContext("t", "d1", "default");
+ DeploymentContext dev2 = tester.newDeploymentContext("t", "d2", "default");
+ assertEquals(version1, dev1.runJob(JobType.dev("us-east-1"), DeploymentContext.applicationPackage()).deployment(ZoneId.from("dev", "us-east-1")).version());
+
+ DeploymentUpgrader devUpgrader = new DeploymentUpgrader(tester.controller(), Duration.ofHours(1));
+ for (int i = 0; i < 24; i++) {
+ tester.clock().advance(Duration.ofHours(1));
+ devUpgrader.run();
+ }
+ dev1.assertNotRunning(JobType.dev("us-east-1"));
+
+ tester.controllerTester().upgradeSystem(version2);
+ tester.upgrader().overrideConfidence(version2, Confidence.low);
+ tester.controllerTester().computeVersionStatus();
+ assertEquals(version1, tester.newDeploymentContext("t", "a4", "default").submit().deploy().application().oldestDeployedPlatform().get());
+ assertEquals(version1, dev1.runJob(JobType.dev("us-east-1"), DeploymentContext.applicationPackage()).deployment(ZoneId.from("dev", "us-east-1")).version());
+ assertEquals(version2, dev2.runJob(JobType.dev("us-east-1"), DeploymentContext.applicationPackage()).deployment(ZoneId.from("dev", "us-east-1")).version());
+
+ for (int i = 0; i < 24; i++) {
+ tester.clock().advance(Duration.ofHours(1));
+ devUpgrader.run();
+ }
+ dev1.assertRunning(JobType.dev("us-east-1"));
+ dev1.runJob(JobType.dev("us-east-1"));
+ assertEquals(version2, dev1.deployment(ZoneId.from("dev", "us-east-1")).version());
+ }
+
+ @Test
void testInstanceWithOnlySystemTestInTwoClouds() {
String spec = """
<deployment>