diff options
author | Jon Marius Venstad <venstad@gmail.com> | 2022-03-14 13:48:09 +0100 |
---|---|---|
committer | Jon Marius Venstad <venstad@gmail.com> | 2022-03-14 13:48:09 +0100 |
commit | 1c0709297c05d9361e3742cb72d7898e70878367 (patch) | |
tree | 669af1581e714b6f1e267db936ff99974cd50558 | |
parent | 0751ede7abd08ba896da97c4c0d04930bfc08383 (diff) |
Append upgrade to revisions with a ccompile version incompatible with current platform
3 files changed, 37 insertions, 3 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 be38ce0c245..fa268fe69b2 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 @@ -87,16 +87,18 @@ public class DeploymentStatus { private final JobList allJobs; private final SystemName system; private final Version systemVersion; + private final List<Integer> incompatibleMajorVersions; private final Instant now; private final Map<JobId, StepStatus> jobSteps; private final List<StepStatus> allSteps; public DeploymentStatus(Application application, Map<JobId, JobStatus> allJobs, SystemName system, - Version systemVersion, Instant now) { + Version systemVersion, List<Integer> incompatibleMajorVersions, Instant now) { this.application = requireNonNull(application); this.allJobs = JobList.from(allJobs.values()); this.system = requireNonNull(system); this.systemVersion = requireNonNull(systemVersion); + this.incompatibleMajorVersions = List.copyOf(incompatibleMajorVersions); this.now = requireNonNull(now); List<StepStatus> allSteps = new ArrayList<>(); this.jobSteps = jobDependencies(application.deploymentSpec(), allSteps); @@ -338,6 +340,16 @@ public class DeploymentStatus { return jobs; } + public boolean isIncompatible(Version platform, Optional<Version> compileVersion) { + return compileVersion.map(version -> incompatibleMajorVersions.stream().anyMatch(major -> major >= platform.getMajor() != major >= version.getMajor())) + .orElse(false); + } + + public boolean isIncompatible(Optional<Version> platform, Optional<ApplicationVersion> application) { + return platform.map(version -> isIncompatible(version, application.flatMap(ApplicationVersion::compileVersion))) + .orElse(false); + } + /** Changes to deploy with the given job, possibly split in two steps. */ private List<Change> changes(JobId job, StepStatus step, Change change) { // Signal strict completion criterion by depending on job itself. 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 12e744292ed..992c9cacc0f 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 @@ -98,20 +98,41 @@ public class DeploymentTrigger { applications().lockApplicationIfPresent(id, application -> { DeploymentStatus status = jobs.deploymentStatus(application.get()); for (InstanceName instanceName : application.get().deploymentSpec().instanceNames()) { - Change outstanding = status.outstandingChange(instanceName); + Change outstanding = outstandingChange(status, instanceName); if ( outstanding.hasTargets() && status.instanceSteps().get(instanceName) .readyAt(outstanding) .map(readyAt -> ! readyAt.isAfter(clock.instant())).orElse(false) && acceptNewApplicationVersion(status, instanceName, outstanding.application().get())) { application = application.with(instanceName, - instance -> withRemainingChange(instance, instance.change().with(outstanding.application().get()), status)); + instance -> withRemainingChange(instance, outstanding.onTopOf(instance.change()), status)); } } applications().store(application); }); } + /** Returns any outstanding change for the given instance, coupled with any necessary platform upgrade. */ + private Change outstandingChange(DeploymentStatus status, InstanceName instance) { + Change outstanding = status.outstandingChange(instance); + Optional<Version> compileVersion = outstanding.application().flatMap(ApplicationVersion::compileVersion); + + // If the outstanding revision requires a certain platform for compatibility, add that here. + if (status.application().productionDeployments().getOrDefault(instance, List.of()).stream() + .anyMatch(deployment -> status.isIncompatible(deployment.version(), compileVersion))) { + return targetsForPolicy(controller.readVersionStatus(), status.application().deploymentSpec().requireInstance(instance).upgradePolicy()) + .stream() // Pick the latest platform which is compatible with the compile version, and is ready for this instance. + .filter(platform -> controller.applications().incompatibleMajorVersions().stream() + .noneMatch(boundary -> platform.getMajor() >= boundary != compileVersion.get().getMajor() >= boundary)) + .map(outstanding::with) + .filter(change -> status.instanceSteps().get(instance).readyAt(change) + .map(readyAt -> ! readyAt.isAfter(controller.clock().instant())) + .orElse(false)) + .findFirst().orElse(Change.empty()); + } + return outstanding; + } + /** Returns target versions for given confidence, by descending version number. */ public List<Version> targetsForPolicy(VersionStatus versions, DeploymentSpec.UpgradePolicy policy) { Version systemVersion = controller.systemVersion(versions); 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 623fcfa2d94..009e594af65 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 @@ -340,6 +340,7 @@ public class JobController { LinkedHashMap::new)), controller.system(), systemVersion, + controller.applications().incompatibleMajorVersions(), controller.clock().instant()); } |