Search in sources :

Example 1 with VespaVersion

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()));
    }
}
Also used : ApplicationVersion(com.yahoo.vespa.hosted.controller.application.ApplicationVersion) VespaVersion(com.yahoo.vespa.hosted.controller.versions.VespaVersion) Version(com.yahoo.component.Version) Deployment(com.yahoo.vespa.hosted.controller.application.Deployment)

Example 2 with VespaVersion

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());
    }
}
Also used : DeploymentStatistics(com.yahoo.vespa.hosted.controller.versions.DeploymentStatistics) VespaVersion(com.yahoo.vespa.hosted.controller.versions.VespaVersion) ArrayList(java.util.ArrayList) VersionStatus(com.yahoo.vespa.hosted.controller.versions.VersionStatus) Test(org.junit.Test)

Example 3 with VespaVersion

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;
}
Also used : ApplicationVersion(com.yahoo.vespa.hosted.controller.application.ApplicationVersion) VespaVersion(com.yahoo.vespa.hosted.controller.versions.VespaVersion) Version(com.yahoo.component.Version) VespaVersion(com.yahoo.vespa.hosted.controller.versions.VespaVersion) ArrayList(java.util.ArrayList) VersionStatus(com.yahoo.vespa.hosted.controller.versions.VersionStatus)

Example 4 with VespaVersion

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));
}
Also used : Version(com.yahoo.component.Version) VespaVersion(com.yahoo.vespa.hosted.controller.versions.VespaVersion) VespaVersion(com.yahoo.vespa.hosted.controller.versions.VespaVersion)

Example 5 with VespaVersion

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)));
}
Also used : AthenzClientFactory(com.yahoo.vespa.hosted.controller.api.integration.athenz.AthenzClientFactory) ArtifactRepository(com.yahoo.vespa.hosted.controller.api.integration.deployment.ArtifactRepository) NodeRepositoryClientInterface(com.yahoo.vespa.hosted.controller.api.integration.noderepository.NodeRepositoryClientInterface) Organization(com.yahoo.vespa.hosted.controller.api.integration.organization.Organization) Version(com.yahoo.component.Version) EntityService(com.yahoo.vespa.hosted.controller.api.integration.entity.EntityService) PropertyId(com.yahoo.vespa.hosted.controller.api.identifiers.PropertyId) Inject(com.google.inject.Inject) DeploymentId(com.yahoo.vespa.hosted.controller.api.identifiers.DeploymentId) Vtag(com.yahoo.component.Vtag) ConfigServerClient(com.yahoo.vespa.hosted.controller.api.integration.configserver.ConfigServerClient) GitHub(com.yahoo.vespa.hosted.controller.api.integration.github.GitHub) Chef(com.yahoo.vespa.hosted.controller.api.integration.chef.Chef) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map) JsonNode(com.fasterxml.jackson.databind.JsonNode) RoutingGenerator(com.yahoo.vespa.hosted.controller.api.integration.routing.RoutingGenerator) MetricsService(com.yahoo.vespa.hosted.controller.api.integration.MetricsService) AthenzDomain(com.yahoo.vespa.athenz.api.AthenzDomain) ControllerDb(com.yahoo.vespa.hosted.controller.persistence.ControllerDb) Predicate(java.util.function.Predicate) CuratorDb(com.yahoo.vespa.hosted.controller.persistence.CuratorDb) ZoneRegistry(com.yahoo.vespa.hosted.controller.api.integration.zone.ZoneRegistry) Logger(java.util.logging.Logger) VespaVersion(com.yahoo.vespa.hosted.controller.versions.VespaVersion) Property(com.yahoo.vespa.hosted.controller.api.identifiers.Property) ApplicationView(com.yahoo.vespa.serviceview.bindings.ApplicationView) Objects(java.util.Objects) List(java.util.List) RotationStatus(com.yahoo.vespa.hosted.controller.api.integration.routing.RotationStatus) AbstractComponent(com.yahoo.component.AbstractComponent) SystemName(com.yahoo.config.provision.SystemName) Clock(java.time.Clock) Optional(java.util.Optional) NameService(com.yahoo.vespa.hosted.controller.api.integration.dns.NameService) RotationsConfig(com.yahoo.vespa.hosted.rotation.config.RotationsConfig) GlobalRoutingService(com.yahoo.vespa.hosted.controller.api.integration.routing.GlobalRoutingService) VersionStatus(com.yahoo.vespa.hosted.controller.versions.VersionStatus) VersionStatus(com.yahoo.vespa.hosted.controller.versions.VersionStatus)

Aggregations

VespaVersion (com.yahoo.vespa.hosted.controller.versions.VespaVersion)7 Version (com.yahoo.component.Version)4 VersionStatus (com.yahoo.vespa.hosted.controller.versions.VersionStatus)3 Cursor (com.yahoo.slime.Cursor)2 Slime (com.yahoo.slime.Slime)2 ApplicationVersion (com.yahoo.vespa.hosted.controller.application.ApplicationVersion)2 SlimeJsonResponse (com.yahoo.vespa.hosted.controller.restapi.SlimeJsonResponse)2 ArrayList (java.util.ArrayList)2 JsonNode (com.fasterxml.jackson.databind.JsonNode)1 Inject (com.google.inject.Inject)1 AbstractComponent (com.yahoo.component.AbstractComponent)1 Vtag (com.yahoo.component.Vtag)1 ApplicationId (com.yahoo.config.provision.ApplicationId)1 SystemName (com.yahoo.config.provision.SystemName)1 AthenzDomain (com.yahoo.vespa.athenz.api.AthenzDomain)1 DeploymentId (com.yahoo.vespa.hosted.controller.api.identifiers.DeploymentId)1 Property (com.yahoo.vespa.hosted.controller.api.identifiers.Property)1 PropertyId (com.yahoo.vespa.hosted.controller.api.identifiers.PropertyId)1 MetricsService (com.yahoo.vespa.hosted.controller.api.integration.MetricsService)1 AthenzClientFactory (com.yahoo.vespa.hosted.controller.api.integration.athenz.AthenzClientFactory)1