diff options
Diffstat (limited to 'controller-server/src/main/java/com/yahoo/vespa/hosted/controller/maintenance')
-rw-r--r-- | controller-server/src/main/java/com/yahoo/vespa/hosted/controller/maintenance/OsUpgradeScheduler.java | 41 |
1 files changed, 24 insertions, 17 deletions
diff --git a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/maintenance/OsUpgradeScheduler.java b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/maintenance/OsUpgradeScheduler.java index 9dd90163683..c751c0a130b 100644 --- a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/maintenance/OsUpgradeScheduler.java +++ b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/maintenance/OsUpgradeScheduler.java @@ -43,9 +43,8 @@ public class OsUpgradeScheduler extends ControllerMaintainer { int attempts = 0; int failures = 0; for (var cloud : controller().clouds()) { - Optional<Change> change = changeIn(cloud, now); + Optional<Change> change = changeIn(cloud, now, false); if (change.isEmpty()) continue; - if (!change.get().scheduleAt(now)) continue; try { attempts++; controller().os().upgradeTo(change.get().osVersion().version(), cloud, false, false); @@ -58,15 +57,24 @@ public class OsUpgradeScheduler extends ControllerMaintainer { return asSuccessFactorDeviation(attempts, failures); } - /** Returns the wanted change for cloud at given instant, if any */ - public Optional<Change> changeIn(CloudName cloud, Instant instant) { + /** + * Returns the next OS version change + * + * @param cloud The cloud where the change will be deployed + * @param now Current time + * @param future Whether to return a change that cannot be scheduled now + */ + public Optional<Change> changeIn(CloudName cloud, Instant now, boolean future) { Optional<OsVersionTarget> currentTarget = controller().os().target(cloud); if (currentTarget.isEmpty()) return Optional.empty(); if (upgradingToNewMajor(cloud)) return Optional.empty(); // Skip further upgrades until major version upgrade is complete - Release release = releaseIn(cloud); - Optional<Change> change = release.change(currentTarget.get().version(), instant); - return change.filter(this::certified); + Version currentVersion = currentTarget.get().version(); + Change change = releaseIn(cloud).change(currentVersion, now); + if (!change.osVersion().version().isAfter(currentVersion)) return Optional.empty(); + if (!future && !change.scheduleAt(now)) return Optional.empty(); + if (!certified(change)) return Optional.empty(); + return Optional.of(change); } private boolean certified(Change change) { @@ -121,8 +129,8 @@ public class OsUpgradeScheduler extends ControllerMaintainer { private interface Release { - /** The pending change for this release at given instant, if any */ - Optional<Change> change(Version currentVersion, Instant instant); + /** The next available change of this release at given instant */ + Change change(Version currentVersion, Instant instant); } @@ -151,12 +159,11 @@ public class OsUpgradeScheduler extends ControllerMaintainer { } @Override - public Optional<Change> change(Version currentVersion, Instant instant) { + public Change change(Version currentVersion, Instant instant) { OsRelease release = artifactRepository.osRelease(currentVersion.getMajor(), tag()); - if (!release.version().isAfter(currentVersion)) return Optional.empty(); Duration cooldown = remainingCooldownOf(cooldown(), release.age(instant)); Instant scheduleAt = schedulingInstant(instant.plus(cooldown), system); - return Optional.of(new Change(new OsVersion(release.version(), cloud), scheduleAt)); + return new Change(new OsVersion(release.version(), cloud), scheduleAt); } /** Returns the release tag tracked by this system */ @@ -193,16 +200,16 @@ public class OsUpgradeScheduler extends ControllerMaintainer { } @Override - public Optional<Change> change(Version currentVersion, Instant instant) { + public Change change(Version currentVersion, Instant instant) { CalendarVersion version = findVersion(instant, currentVersion); - Instant predicatedInstant = instant; + Instant predicted = instant; while (!version.version().isAfter(currentVersion)) { - predicatedInstant = predicatedInstant.plus(Duration.ofDays(1)); - version = findVersion(predicatedInstant, currentVersion); + predicted = predicted.plus(Duration.ofDays(1)); + version = findVersion(predicted, currentVersion); } Duration cooldown = remainingCooldownOf(COOLDOWN, version.age(instant)); Instant schedulingInstant = schedulingInstant(instant.plus(cooldown), system); - return Optional.of(new Change(new OsVersion(version.version(), cloud), schedulingInstant)); + return new Change(new OsVersion(version.version(), cloud), schedulingInstant); } /** Find the most recent version available according to the scheduling step, relative to now */ |