diff options
author | Jon Marius Venstad <venstad@gmail.com> | 2021-11-30 10:31:53 +0100 |
---|---|---|
committer | Jon Marius Venstad <venstad@gmail.com> | 2021-11-30 10:31:53 +0100 |
commit | daef832e7805139337eb6926d3c4b33cd5e0696d (patch) | |
tree | 2e15b75a4c35f434d291420dd04b09f8f4906d01 /controller-server | |
parent | 1c3caafc1d8b877dfc390e425bb25cc473f56fa3 (diff) |
Recompute change to avoid setting a change which triggers no jobs
Diffstat (limited to 'controller-server')
2 files changed, 22 insertions, 2 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 3892ceeddf9..4e8f17b6098 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 @@ -277,8 +277,13 @@ public class DeploymentTrigger { /** Overrides the given instance's platform and application changes with any contained in the given change. */ public void forceChange(ApplicationId instanceId, Change change) { applications().lockApplicationOrThrow(TenantAndApplicationId.from(instanceId), application -> { - applications().store(application.with(instanceId.instance(), - instance -> instance.withChange(change.onTopOf(application.get().require(instanceId.instance()).change())))); + Change newChange = change.onTopOf(application.get().require(instanceId.instance()).change()); + application = application.with(instanceId.instance(), + instance -> instance.withChange(newChange)); + DeploymentStatus newStatus = jobs.deploymentStatus(application.get()); + application = application.with(instanceId.instance(), + instance -> instance.withChange(remainingChange(instance, newStatus))); + applications().store(application); }); } 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 1f5fa243838..102dfde16ec 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 @@ -465,6 +465,21 @@ public class DeploymentTriggerTest { } @Test + public void settingANoOpChangeIsANoOp() { + var app = tester.newDeploymentContext().submit().deploy(); + ApplicationVersion appVersion0 = app.lastSubmission().get(); + app.submit().deploy(); + ApplicationVersion appVersion1 = app.lastSubmission().get(); + + // Triggering a roll-out of an already deployed application is a no-op. + assertEquals(Change.empty(), app.instance().change()); + tester.deploymentTrigger().forceChange(app.instanceId(), Change.of(appVersion0)); + assertEquals(Change.empty(), app.instance().change()); + tester.deploymentTrigger().forceChange(app.instanceId(), Change.of(appVersion1)); + assertEquals(Change.empty(), app.instance().change()); + } + + @Test public void stepIsCompletePreciselyWhenItShouldBe() { var app1 = tester.newDeploymentContext("tenant1", "app1", "default"); var app2 = tester.newDeploymentContext("tenant1", "app2", "default"); |