diff options
author | Jon Marius Venstad <jvenstad@yahoo-inc.com> | 2019-01-23 09:37:49 +0100 |
---|---|---|
committer | Jon Marius Venstad <jvenstad@yahoo-inc.com> | 2019-01-23 09:37:49 +0100 |
commit | 65f9fad6f9255e693d3537620bbaac4d2443f9a3 (patch) | |
tree | 8f602167db3fdb0b5a90c281055fc9cea6b5a74f /controller-server | |
parent | 7f89340cdcb5cf49e88ab4dbd97a3cf49ad3eedf (diff) |
Revert "Default to system version when deploying to dev"
This reverts commit 416ae7ee0bc8431eca0a4de5c014c232bd786f06.
Diffstat (limited to 'controller-server')
2 files changed, 22 insertions, 1 deletions
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 3185b7d5f45..da0f7750995 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 @@ -58,6 +58,7 @@ import com.yahoo.vespa.hosted.controller.rotation.RotationLock; import com.yahoo.vespa.hosted.controller.rotation.RotationRepository; import com.yahoo.vespa.hosted.controller.tenant.AthenzTenant; import com.yahoo.vespa.hosted.controller.tenant.Tenant; +import com.yahoo.vespa.hosted.controller.versions.VespaVersion; import com.yahoo.vespa.hosted.rotation.config.RotationsConfig; import com.yahoo.yolean.Exceptions; @@ -67,8 +68,10 @@ import java.net.URI; import java.time.Clock; import java.time.Duration; import java.time.Instant; +import java.util.ArrayDeque; import java.util.Collections; import java.util.Comparator; +import java.util.Deque; import java.util.EnumSet; import java.util.HashSet; import java.util.List; @@ -277,7 +280,9 @@ public class ApplicationController { ApplicationVersion applicationVersion; ApplicationPackage applicationPackage; if (canDeployDirectly) { - platformVersion = options.vespaVersion.map(Version::new).orElse(controller.systemVersion()); + platformVersion = options.vespaVersion.map(Version::new).orElse(curator.readTargetMajorVersion() + .flatMap(this::lastCompatibleVersion) + .orElse(controller.systemVersion())); applicationVersion = applicationVersionFromDeployer.orElse(ApplicationVersion.unknown); applicationPackage = applicationPackageFromDeployer.orElseThrow( () -> new IllegalArgumentException("Application package must be given when deploying to " + zone)); @@ -727,6 +732,14 @@ public class ApplicationController { }); } + /** Returns the latest known version within the given major. */ + private Optional<Version> lastCompatibleVersion(int targetMajorVersion) { + return controller.versionStatus().versions().stream() + .map(VespaVersion::versionNumber) + .filter(version -> version.getMajor() == targetMajorVersion) + .max(naturalOrder()); + } + private boolean isUserDeployment(Optional<AthenzIdentity> identity) { return identity .filter(id -> id instanceof AthenzUser) diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/ControllerTest.java b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/ControllerTest.java index 1199f0229b6..66aa35782f0 100644 --- a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/ControllerTest.java +++ b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/ControllerTest.java @@ -446,6 +446,8 @@ public class ControllerTest { @Test public void testDeployDirectly() { DeploymentTester tester = new DeploymentTester(); + Version six = Version.fromString("6.1"); + tester.upgradeSystem(six); tester.controllerTester().zoneRegistry().setSystemName(SystemName.cd); tester.controllerTester().zoneRegistry().setZones(ZoneId.from("prod", "cd-us-central-1")); ApplicationPackage applicationPackage = new ApplicationPackageBuilder() @@ -468,6 +470,12 @@ public class ControllerTest { assertTrue("No job status added", tester.applications().require(app.id()).deploymentJobs().jobStatus().isEmpty()); + + Version seven = Version.fromString("7.2"); + tester.upgrader().setTargetMajorVersion(Optional.of(6)); + tester.upgradeSystem(seven); + tester.controller().applications().deploy(app.id(), zone, Optional.of(applicationPackage), options); + assertEquals(six, tester.application(app.id()).deployments().get(zone).version()); } @Test |