use of com.yahoo.vespa.hosted.controller.versions.VespaVersion in project vespa by vespa-engine.
the class ControllerTest method runDeployment.
private void runDeployment(DeploymentTester tester, Application app, ApplicationVersion version, Optional<Version> upgrade, Optional<ApplicationPackage> applicationPackage) {
Version vespaVersion = upgrade.orElseGet(tester::defaultVespaVersion);
// Deploy in test
tester.deployAndNotify(app, applicationPackage, true, true, systemTest);
tester.deployAndNotify(app, applicationPackage, true, true, stagingTest);
assertStatus(JobStatus.initial(stagingTest).withTriggering(vespaVersion, version, "", tester.clock().instant().minus(Duration.ofMillis(1))).withCompletion(42, Optional.empty(), tester.clock().instant(), tester.controller()), app.id(), tester.controller());
// Deploy in production
tester.deployAndNotify(app, applicationPackage, true, true, productionCorpUsEast1);
assertStatus(JobStatus.initial(productionCorpUsEast1).withTriggering(vespaVersion, version, "", tester.clock().instant().minus(Duration.ofMillis(1))).withCompletion(42, Optional.empty(), tester.clock().instant(), tester.controller()), app.id(), tester.controller());
tester.deployAndNotify(app, applicationPackage, true, true, productionUsEast3);
assertStatus(JobStatus.initial(productionUsEast3).withTriggering(vespaVersion, version, "", tester.clock().instant().minus(Duration.ofMillis(1))).withCompletion(42, Optional.empty(), tester.clock().instant(), tester.controller()), app.id(), tester.controller());
// Verify deployed version
app = tester.controller().applications().require(app.id());
for (Deployment deployment : app.productionDeployments().values()) {
assertEquals(version, deployment.applicationVersion());
upgrade.ifPresent(v -> assertEquals(v, deployment.version()));
}
}
use of com.yahoo.vespa.hosted.controller.versions.VespaVersion in project vespa by vespa-engine.
the class VersionStatusSerializerTest method testSerialization.
@Test
public void testSerialization() {
List<VespaVersion> vespaVersions = new ArrayList<>();
DeploymentStatistics statistics = new DeploymentStatistics(Version.fromString("5.0"), Arrays.asList(ApplicationId.from("tenant1", "failing1", "default")), Arrays.asList(ApplicationId.from("tenant2", "success1", "default"), ApplicationId.from("tenant2", "success2", "default")), Arrays.asList(ApplicationId.from("tenant1", "failing1", "default"), ApplicationId.from("tenant2", "success2", "default")));
vespaVersions.add(new VespaVersion(statistics, "dead", Instant.now(), false, Arrays.asList("cfg1", "cfg2", "cfg3"), VespaVersion.Confidence.normal));
vespaVersions.add(new VespaVersion(statistics, "cafe", Instant.now(), true, Arrays.asList("cfg1", "cfg2", "cfg3"), VespaVersion.Confidence.normal));
VersionStatus status = new VersionStatus(vespaVersions);
VersionStatusSerializer serializer = new VersionStatusSerializer();
VersionStatus deserialized = serializer.fromSlime(serializer.toSlime(status));
assertEquals(status.versions().size(), deserialized.versions().size());
for (int i = 0; i < status.versions().size(); i++) {
VespaVersion a = status.versions().get(i);
VespaVersion b = deserialized.versions().get(i);
assertEquals(a.releaseCommit(), b.releaseCommit());
assertEquals(a.committedAt(), b.committedAt());
assertEquals(a.isCurrentSystemVersion(), b.isCurrentSystemVersion());
assertEquals(a.statistics(), b.statistics());
assertEquals(a.configServerHostnames(), b.configServerHostnames());
assertEquals(a.confidence(), b.confidence());
}
}
use of com.yahoo.vespa.hosted.controller.versions.VespaVersion in project vespa by vespa-engine.
the class ControllerTest method incrementSystemVersion.
/**
* Adds a new version, higher than the current system version, makes it the system version and returns it
*/
private Version incrementSystemVersion(Controller controller) {
Version systemVersion = controller.versionStatus().systemVersion().get().versionNumber();
Version newSystemVersion = new Version(systemVersion.getMajor(), systemVersion.getMinor() + 1, 0);
VespaVersion newSystemVespaVersion = new VespaVersion(DeploymentStatistics.empty(newSystemVersion), "commit1", Instant.now(), true, Collections.emptyList(), VespaVersion.Confidence.low);
List<VespaVersion> versions = new ArrayList<>(controller.versionStatus().versions());
for (int i = 0; i < versions.size(); i++) {
VespaVersion c = versions.get(i);
if (c.isCurrentSystemVersion())
versions.set(i, new VespaVersion(c.statistics(), c.releaseCommit(), c.committedAt(), false, c.configServerHostnames(), c.confidence()));
}
versions.add(newSystemVespaVersion);
controller.updateVersionStatus(new VersionStatus(versions));
return newSystemVersion;
}
use of com.yahoo.vespa.hosted.controller.versions.VespaVersion in project vespa by vespa-engine.
the class Upgrader method maintain.
/**
* Schedule application upgrades. Note that this implementation must be idempotent.
*/
@Override
public void maintain() {
// Determine target versions for each upgrade policy
Optional<Version> canaryTarget = controller().versionStatus().systemVersion().map(VespaVersion::versionNumber);
Optional<Version> defaultTarget = newestVersionWithConfidence(Confidence.normal);
Optional<Version> conservativeTarget = newestVersionWithConfidence(Confidence.high);
// Cancel upgrades to broken targets (let other ongoing upgrades complete to avoid starvation
for (VespaVersion version : controller().versionStatus().versions()) {
if (version.confidence() == Confidence.broken)
cancelUpgradesOf(applications().without(UpgradePolicy.canary).upgradingTo(version.versionNumber()), version.versionNumber() + " is broken");
}
// Canaries should always try the canary target
cancelUpgradesOf(applications().with(UpgradePolicy.canary).upgrading().notUpgradingTo(canaryTarget), "Outdated target version for Canaries");
// Cancel *failed* upgrades to earlier versions, as the new version may fix it
String reason = "Failing on outdated version";
cancelUpgradesOf(applications().with(UpgradePolicy.defaultPolicy).upgrading().failing().notUpgradingTo(defaultTarget), reason);
cancelUpgradesOf(applications().with(UpgradePolicy.conservative).upgrading().failing().notUpgradingTo(conservativeTarget), reason);
// Schedule the right upgrades
canaryTarget.ifPresent(target -> upgrade(applications().with(UpgradePolicy.canary), target));
defaultTarget.ifPresent(target -> upgrade(applications().with(UpgradePolicy.defaultPolicy), target));
conservativeTarget.ifPresent(target -> upgrade(applications().with(UpgradePolicy.conservative), target));
}
use of com.yahoo.vespa.hosted.controller.versions.VespaVersion in project vespa by vespa-engine.
the class Controller method updateVersionStatus.
/**
* Replace the current version status by a new one
*/
public void updateVersionStatus(VersionStatus newStatus) {
VersionStatus currentStatus = versionStatus();
if (newStatus.systemVersion().isPresent() && !newStatus.systemVersion().equals(currentStatus.systemVersion())) {
log.info("Changing system version from " + printableVersion(currentStatus.systemVersion()) + " to " + printableVersion(newStatus.systemVersion()));
}
curator.writeVersionStatus(newStatus);
// Removes confidence overrides for versions that no longer exist in the system
removeConfidenceOverride(version -> newStatus.versions().stream().noneMatch(vespaVersion -> vespaVersion.versionNumber().equals(version)));
}
Aggregations