diff options
author | Jon Marius Venstad <venstad@gmail.com> | 2022-01-20 11:35:47 +0100 |
---|---|---|
committer | Jon Marius Venstad <venstad@gmail.com> | 2022-01-20 11:35:47 +0100 |
commit | 5e9b806c19c95a26397c499cef0cd070ef7c5a38 (patch) | |
tree | edbc95888877b3a2904310ffbb17b5f9870c9610 /controller-server | |
parent | 66c770f457c93e9b8a5b0b4b60a0bf2abb628bfd (diff) |
Simplify remaining change code, no functional changes
Diffstat (limited to 'controller-server')
2 files changed, 14 insertions, 27 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 e7521b37dbf..0c4ef71044a 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 @@ -237,7 +237,7 @@ public class DeploymentStatus { } private Map<JobId, Versions> productionJobs(InstanceName instance, Change change, boolean assumeUpgradesSucceed) { - ImmutableMap.Builder<JobId, Versions> jobs = ImmutableMap.builder(); + Map<JobId, Versions> jobs = new LinkedHashMap<>(); jobSteps.forEach((job, step) -> { // When computing eager test jobs for outstanding changes, assume current upgrade completes successfully. Optional<Deployment> deployment = deploymentFor(job) @@ -255,12 +255,7 @@ public class DeploymentStatus { && step.completedAt(change).isEmpty()) jobs.put(job, Versions.from(change, application, deployment, systemVersion)); }); - return jobs.build(); - } - - /** The production jobs that need to run to complete roll-out of the given change to production. */ - public Map<JobId, Versions> productionJobs(InstanceName instance, Change change) { - return productionJobs(instance, change, false); + return jobs; } /** The test jobs that need to run prior to the given production deployment 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 4e8f17b6098..194fb74a045 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 @@ -99,10 +99,7 @@ public class DeploymentTrigger { .map(readyAt -> ! readyAt.isAfter(clock.instant())).orElse(false) && acceptNewApplicationVersion(status, instanceName)) { application = application.with(instanceName, - instance -> { - instance = instance.withChange(instance.change().with(outstanding.application().get())); - return instance.withChange(remainingChange(instance, status)); - }); + instance -> withRemainingChange(instance, instance.change().with(outstanding.application().get()), status)); } } applications().store(application); @@ -121,7 +118,7 @@ public class DeploymentTrigger { applications().lockApplicationOrThrow(TenantAndApplicationId.from(id), application -> applications().store(application.with(id.instance(), - instance -> instance.withChange(remainingChange(instance, jobs.deploymentStatus(application.get())))))); + instance -> withRemainingChange(instance, instance.change(), jobs.deploymentStatus(application.get()))))); } /** @@ -277,13 +274,8 @@ 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 -> { - 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); + applications().store(application.with(instanceId.instance(), + instance -> withRemainingChange(instance, change.onTopOf(application.get().require(instanceId.instance()).change()), jobs.deploymentStatus(application.get())))); }); } @@ -300,7 +292,7 @@ public class DeploymentTrigger { default: throw new IllegalArgumentException("Unknown cancellation choice '" + cancellation + "'!"); } applications().store(application.with(instanceId.instance(), - instance -> instance.withChange(change))); + instance -> withRemainingChange(instance, change, jobs.deploymentStatus(application.get())))); }); } @@ -379,13 +371,13 @@ public class DeploymentTrigger { return status.application().require(instance).change().platform().isEmpty(); } - private Change remainingChange(Instance instance, DeploymentStatus status) { - Change change = instance.change(); - if (status.jobsToRun(Map.of(instance.name(), instance.change().withoutApplication())).isEmpty()) - change = change.withoutPlatform(); - if (status.jobsToRun(Map.of(instance.name(), instance.change().withoutPlatform())).isEmpty()) - change = change.withoutApplication(); - return change; + private Instance withRemainingChange(Instance instance, Change change, DeploymentStatus status) { + Change remaining = change; + if (status.jobsToRun(Map.of(instance.name(), change.withoutApplication())).isEmpty()) + remaining = remaining.withoutPlatform(); + if (status.jobsToRun(Map.of(instance.name(), change.withoutPlatform())).isEmpty()) + remaining = remaining.withoutApplication(); + return instance.withChange(remaining); } // ---------- Version and job helpers ---------- |