summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJon Marius Venstad <jvenstad@yahoo-inc.com>2019-01-08 15:52:31 +0100
committerJon Marius Venstad <jvenstad@yahoo-inc.com>2019-01-08 15:52:31 +0100
commitcfa7fa159def70ad6dc084dcf5eb08493a5f66e1 (patch)
tree6151c864dd1ca7dc9e79b8a01c5ee661c4c9f674
parentd426643d93cf13c8dab4d85c59768e9dd0c3cb57 (diff)
Allow removal of more parts of change, and test pin scenario
-rw-r--r--controller-server/src/main/java/com/yahoo/vespa/hosted/controller/deployment/DeploymentTrigger.java4
-rw-r--r--controller-server/src/test/java/com/yahoo/vespa/hosted/controller/maintenance/UpgraderTest.java66
2 files changed, 69 insertions, 1 deletions
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 f36b7c8dedb..54076633e4e 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
@@ -256,15 +256,17 @@ public class DeploymentTrigger {
Change change;
switch (cancellation) {
case ALL: change = Change.empty(); break;
+ case VERSIONS: change = Change.empty().withPin(); break;
case PLATFORM: change = application.get().change().withoutPlatform(); break;
case APPLICATION: change = application.get().change().withoutApplication(); break;
+ case PIN: change = application.get().change().withoutPin(); break;
default: throw new IllegalArgumentException("Unknown cancellation choice '" + cancellation + "'!");
}
applications().store(application.withChange(change));
});
}
- public enum ChangesToCancel { ALL, PLATFORM, APPLICATION }
+ public enum ChangesToCancel { ALL, PLATFORM, APPLICATION, VERSIONS, PIN }
// ---------- Conveniences ----------
diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/maintenance/UpgraderTest.java b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/maintenance/UpgraderTest.java
index b81d9e78339..4088c61b0b6 100644
--- a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/maintenance/UpgraderTest.java
+++ b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/maintenance/UpgraderTest.java
@@ -10,8 +10,10 @@ import com.yahoo.vespa.hosted.controller.ControllerTester;
import com.yahoo.vespa.hosted.controller.api.integration.deployment.JobType;
import com.yahoo.vespa.hosted.controller.api.integration.zone.ZoneId;
import com.yahoo.vespa.hosted.controller.application.ApplicationPackage;
+import com.yahoo.vespa.hosted.controller.application.Change;
import com.yahoo.vespa.hosted.controller.application.Deployment;
import com.yahoo.vespa.hosted.controller.deployment.ApplicationPackageBuilder;
+import com.yahoo.vespa.hosted.controller.deployment.BuildJob;
import com.yahoo.vespa.hosted.controller.deployment.DeploymentTester;
import com.yahoo.vespa.hosted.controller.versions.VespaVersion;
import org.junit.Before;
@@ -29,6 +31,7 @@ import static com.yahoo.vespa.hosted.controller.api.integration.deployment.JobTy
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 com.yahoo.vespa.hosted.controller.deployment.DeploymentTrigger.ChangesToCancel.ALL;
+import static com.yahoo.vespa.hosted.controller.deployment.DeploymentTrigger.ChangesToCancel.PIN;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
@@ -1132,4 +1135,67 @@ public class UpgraderTest {
assertFalse(tester.application(app.id()).change().isPresent());
}
+ @Test
+ public void testPinning() {
+ Version version0 = Version.fromString("6.2");
+ tester.upgradeSystem(version0);
+
+ // Create an application with pinned platform version.
+ Application application = tester.createApplication("application", "tenant", 2, 3);
+ ApplicationPackage applicationPackage = new ApplicationPackageBuilder().environment(Environment.prod)
+ .region("us-east-3")
+ .region("us-west-1")
+ .build();
+ tester.deploymentTrigger().forceChange(application.id(), Change.empty().withPin());
+
+ tester.deployCompletely(application, applicationPackage);
+ assertFalse(tester.application(application.id()).change().isPresent());
+ assertTrue(tester.application(application.id()).change().isPinning());
+ assertEquals(2, tester.application(application.id()).deployments().size());
+
+ // Application does not upgrade.
+ Version version1 = Version.fromString("6.3");
+ tester.upgradeSystem(version1);
+ tester.upgrader().maintain();
+ assertFalse(tester.application(application.id()).change().isPresent());
+ assertTrue(tester.application(application.id()).change().isPinning());
+
+ // New application package is deployed.
+ tester.deployCompletely(application, applicationPackage, BuildJob.defaultBuildNumber + 1);
+ assertFalse(tester.application(application.id()).change().isPresent());
+ assertTrue(tester.application(application.id()).change().isPinning());
+
+ // Application upgrades to new version when pin is removed.
+ tester.deploymentTrigger().cancelChange(application.id(), PIN);
+ tester.upgrader().maintain();
+ assertTrue(tester.application(application.id()).change().isPresent());
+ assertFalse(tester.application(application.id()).change().isPinning());
+
+ // Application is pinned to new version, and upgrade is therefore not cancelled, even though confidence is broken.
+ tester.deploymentTrigger().forceChange(application.id(), Change.empty().withPin());
+ tester.upgrader().maintain();
+ tester.readyJobTrigger().maintain();
+ assertEquals(version1, tester.application(application.id()).change().platform().get());
+
+ // Application fails upgrade after one zone is complete, and is pinned again to the old version.
+ tester.deployAndNotify(application, true, systemTest);
+ tester.deployAndNotify(application, true, stagingTest);
+ tester.deployAndNotify(application, true, productionUsEast3);
+ tester.deploy(productionUsWest1, application, Optional.empty(), false);
+ tester.deployAndNotify(application, false, productionUsWest1);
+ tester.deploymentTrigger().cancelChange(application.id(), ALL);
+ tester.deploymentTrigger().forceChange(application.id(), Change.of(version0).withPin());
+ tester.buildService().clear();
+ assertEquals(version0, tester.application(application.id()).change().platform().get());
+
+ // Application downgrades to pinned version.
+ tester.readyJobTrigger().maintain();
+ tester.deployAndNotify(application, true, systemTest);
+ tester.deployAndNotify(application, true, stagingTest);
+ tester.deployAndNotify(application, true, productionUsEast3);
+ assertTrue(tester.application(application.id()).change().isPresent());
+ tester.deployAndNotify(application, true, productionUsWest1);
+ assertFalse(tester.application(application.id()).change().isPresent());
+ }
+
}