Search in sources :

Example 66 with Version

use of com.yahoo.component.Version in project vespa by vespa-engine.

the class DockerProvisioningTest method docker_application_deployment.

@Test
public void docker_application_deployment() {
    ProvisioningTester tester = new ProvisioningTester(new Zone(Environment.prod, RegionName.from("us-east")));
    ApplicationId application1 = tester.makeApplicationId();
    for (int i = 1; i < 10; i++) tester.makeReadyDockerNodes(1, dockerFlavor, "dockerHost" + i);
    Version wantedVespaVersion = Version.fromString("6.39");
    int nodeCount = 7;
    List<HostSpec> hosts = tester.prepare(application1, ClusterSpec.request(ClusterSpec.Type.content, ClusterSpec.Id.from("myContent"), wantedVespaVersion, false), nodeCount, 1, dockerFlavor);
    tester.activate(application1, new HashSet<>(hosts));
    NodeList nodes = tester.getNodes(application1, Node.State.active);
    assertEquals(nodeCount, nodes.size());
    assertEquals(dockerFlavor, nodes.asList().get(0).flavor().canonicalName());
    // Upgrade Vespa version on nodes
    Version upgradedWantedVespaVersion = Version.fromString("6.40");
    List<HostSpec> upgradedHosts = tester.prepare(application1, ClusterSpec.request(ClusterSpec.Type.content, ClusterSpec.Id.from("myContent"), upgradedWantedVespaVersion, false), nodeCount, 1, dockerFlavor);
    tester.activate(application1, new HashSet<>(upgradedHosts));
    NodeList upgradedNodes = tester.getNodes(application1, Node.State.active);
    assertEquals(nodeCount, upgradedNodes.size());
    assertEquals(dockerFlavor, upgradedNodes.asList().get(0).flavor().canonicalName());
    assertEquals(hosts, upgradedHosts);
}
Also used : Version(com.yahoo.component.Version) Zone(com.yahoo.config.provision.Zone) NodeList(com.yahoo.vespa.hosted.provision.NodeList) ApplicationId(com.yahoo.config.provision.ApplicationId) HostSpec(com.yahoo.config.provision.HostSpec) Test(org.junit.Test)

Example 67 with Version

use of com.yahoo.component.Version in project vespa by vespa-engine.

the class ApplicationController method deployApplication.

/**
 * Deploys an application. If the application does not exist it is created.
 */
// TODO: Get rid of the options arg
public ActivateResult deployApplication(ApplicationId applicationId, ZoneId zone, Optional<ApplicationPackage> applicationPackageFromDeployer, DeployOptions options) {
    try (Lock lock = lock(applicationId)) {
        LockedApplication application = get(applicationId).map(app -> new LockedApplication(app, lock)).orElseGet(() -> new LockedApplication(createApplication(applicationId, Optional.empty()), lock));
        final boolean canDeployDirectly = canDeployDirectlyTo(zone, options);
        // Determine Vespa version to use
        Version version;
        if (options.deployCurrentVersion) {
            version = application.versionIn(zone, controller);
        } else if (canDeployDirectlyTo(zone, options)) {
            version = options.vespaVersion.map(Version::new).orElse(controller.systemVersion());
        } else if (!application.change().isPresent() && !zone.environment().isManuallyDeployed()) {
            return unexpectedDeployment(applicationId, zone, applicationPackageFromDeployer);
        } else {
            version = application.deployVersionIn(zone, controller);
        }
        // Determine application package to use
        Pair<ApplicationPackage, ApplicationVersion> artifact = artifactFor(zone, application, applicationPackageFromDeployer, canDeployDirectly, options.deployCurrentVersion);
        ApplicationPackage applicationPackage = artifact.getFirst();
        ApplicationVersion applicationVersion = artifact.getSecond();
        validate(applicationPackage.deploymentSpec());
        // Update application with information from application package
        if (!options.deployCurrentVersion) {
            // Store information about application package
            application = application.with(applicationPackage.deploymentSpec());
            application = application.with(applicationPackage.validationOverrides());
            // Delete zones not listed in DeploymentSpec, if allowed
            // We do this at deployment time to be able to return a validation failure message when necessary
            application = deleteRemovedDeployments(application);
            // Clean up deployment jobs that are no longer referenced by deployment spec
            application = deleteUnreferencedDeploymentJobs(application);
            // TODO jvenstad: Store triggering information here, including versions, when job status is read from the build service.
            // store missing information even if we fail deployment below
            store(application);
        }
        // Validate the change being deployed
        if (!canDeployDirectly) {
            validateChange(application, zone, version);
        }
        // Assign global rotation
        application = withRotation(application, zone);
        Set<String> rotationNames = new HashSet<>();
        Set<String> cnames = new HashSet<>();
        application.rotation().ifPresent(applicationRotation -> {
            rotationNames.add(applicationRotation.id().asString());
            cnames.add(applicationRotation.dnsName());
            cnames.add(applicationRotation.secureDnsName());
        });
        // Carry out deployment
        options = withVersion(version, options);
        ConfigServerClient.PreparedApplication preparedApplication = configServer.prepare(new DeploymentId(applicationId, zone), options, cnames, rotationNames, applicationPackage.zippedContent());
        preparedApplication.activate();
        application = application.withNewDeployment(zone, applicationVersion, version, clock.instant());
        store(application);
        return new ActivateResult(new RevisionId(applicationPackage.hash()), preparedApplication.prepareResponse(), applicationPackage.zippedContent().length);
    }
}
Also used : ArtifactRepository(com.yahoo.vespa.hosted.controller.api.integration.deployment.ArtifactRepository) ZmsClient(com.yahoo.vespa.hosted.controller.api.integration.athenz.ZmsClient) EndpointStatus(com.yahoo.vespa.hosted.controller.api.application.v4.model.EndpointStatus) DeploymentTrigger(com.yahoo.vespa.hosted.controller.deployment.DeploymentTrigger) URISyntaxException(java.net.URISyntaxException) DeploymentJobs(com.yahoo.vespa.hosted.controller.application.DeploymentJobs) ValidationId(com.yahoo.config.application.api.ValidationId) JobReport(com.yahoo.vespa.hosted.controller.application.DeploymentJobs.JobReport) TenantName(com.yahoo.config.provision.TenantName) Tenant(com.yahoo.vespa.hosted.controller.api.Tenant) ZoneId(com.yahoo.vespa.hosted.controller.api.integration.zone.ZoneId) DeploymentExpirer(com.yahoo.vespa.hosted.controller.maintenance.DeploymentExpirer) RevisionId(com.yahoo.vespa.hosted.controller.api.identifiers.RevisionId) Duration(java.time.Duration) Map(java.util.Map) DeployOptions(com.yahoo.vespa.hosted.controller.api.application.v4.model.DeployOptions) URI(java.net.URI) Rotation(com.yahoo.vespa.hosted.controller.rotation.Rotation) Exceptions(com.yahoo.yolean.Exceptions) RotationRepository(com.yahoo.vespa.hosted.controller.rotation.RotationRepository) ApplicationVersion(com.yahoo.vespa.hosted.controller.application.ApplicationVersion) Set(java.util.Set) Logger(java.util.logging.Logger) Collectors(java.util.stream.Collectors) List(java.util.List) Optional(java.util.Optional) Deployment(com.yahoo.vespa.hosted.controller.application.Deployment) RotationsConfig(com.yahoo.vespa.hosted.rotation.config.RotationsConfig) Log(com.yahoo.vespa.hosted.controller.api.integration.configserver.Log) AthenzClientFactory(com.yahoo.vespa.hosted.controller.api.integration.athenz.AthenzClientFactory) Version(com.yahoo.component.Version) ApplicationId(com.yahoo.config.provision.ApplicationId) DeploymentId(com.yahoo.vespa.hosted.controller.api.identifiers.DeploymentId) RecordId(com.yahoo.vespa.hosted.controller.api.integration.dns.RecordId) ConfigServerClient(com.yahoo.vespa.hosted.controller.api.integration.configserver.ConfigServerClient) HashMap(java.util.HashMap) NToken(com.yahoo.vespa.athenz.api.NToken) ArrayList(java.util.ArrayList) Level(java.util.logging.Level) HashSet(java.util.HashSet) ConfigChangeActions(com.yahoo.vespa.hosted.controller.api.application.v4.model.configserverbindings.ConfigChangeActions) ImmutableList(com.google.common.collect.ImmutableList) TenantId(com.yahoo.vespa.hosted.controller.api.identifiers.TenantId) RecordData(com.yahoo.vespa.hosted.controller.api.integration.dns.RecordData) RoutingEndpoint(com.yahoo.vespa.hosted.controller.api.integration.routing.RoutingEndpoint) RoutingGenerator(com.yahoo.vespa.hosted.controller.api.integration.routing.RoutingGenerator) ActivateResult(com.yahoo.vespa.hosted.controller.api.ActivateResult) NoInstanceException(com.yahoo.vespa.hosted.controller.api.integration.configserver.NoInstanceException) Lock(com.yahoo.vespa.curator.Lock) Hostname(com.yahoo.vespa.hosted.controller.api.identifiers.Hostname) Environment(com.yahoo.config.provision.Environment) ControllerDb(com.yahoo.vespa.hosted.controller.persistence.ControllerDb) CuratorDb(com.yahoo.vespa.hosted.controller.persistence.CuratorDb) IOException(java.io.IOException) ApplicationPackage(com.yahoo.vespa.hosted.controller.application.ApplicationPackage) Consumer(java.util.function.Consumer) Pair(com.yahoo.collections.Pair) DeploymentSpec(com.yahoo.config.application.api.DeploymentSpec) RecordName(com.yahoo.vespa.hosted.controller.api.integration.dns.RecordName) Clock(java.time.Clock) NameService(com.yahoo.vespa.hosted.controller.api.integration.dns.NameService) PrepareResponse(com.yahoo.vespa.hosted.controller.api.integration.configserver.PrepareResponse) Collections(java.util.Collections) Record(com.yahoo.vespa.hosted.controller.api.integration.dns.Record) RotationLock(com.yahoo.vespa.hosted.controller.rotation.RotationLock) DeploymentId(com.yahoo.vespa.hosted.controller.api.identifiers.DeploymentId) ApplicationVersion(com.yahoo.vespa.hosted.controller.application.ApplicationVersion) ApplicationPackage(com.yahoo.vespa.hosted.controller.application.ApplicationPackage) RevisionId(com.yahoo.vespa.hosted.controller.api.identifiers.RevisionId) Lock(com.yahoo.vespa.curator.Lock) RotationLock(com.yahoo.vespa.hosted.controller.rotation.RotationLock) ActivateResult(com.yahoo.vespa.hosted.controller.api.ActivateResult) ApplicationVersion(com.yahoo.vespa.hosted.controller.application.ApplicationVersion) Version(com.yahoo.component.Version) ConfigServerClient(com.yahoo.vespa.hosted.controller.api.integration.configserver.ConfigServerClient) HashSet(java.util.HashSet)

Example 68 with Version

use of com.yahoo.component.Version in project vespa by vespa-engine.

the class DeploymentTrigger method changeDeployed.

/**
 * Returns whether the given application should skip deployment of its current change to the given production job zone.
 *
 * If the currently deployed application has a newer platform or application version than the application's
 * current change, the method returns {@code true}, to avoid a downgrade.
 * Otherwise, it returns whether the current change is redundant, i.e., all its components are already deployed.
 */
private boolean changeDeployed(Application application, JobType job) {
    if (!job.isProduction())
        throw new IllegalArgumentException(job + " is not a production job!");
    Deployment deployment = application.deployments().get(job.zone(controller.system()).get());
    if (deployment == null)
        return false;
    int applicationComparison = application.change().application().map(version -> version.compareTo(deployment.applicationVersion())).orElse(0);
    int platformComparion = application.change().platform().map(version -> version.compareTo(deployment.version())).orElse(0);
    if (applicationComparison == -1 || platformComparion == -1)
        // Avoid downgrades!
        return true;
    return applicationComparison == 0 && platformComparion == 0;
}
Also used : Version(com.yahoo.component.Version) ApplicationId(com.yahoo.config.provision.ApplicationId) JobReport(com.yahoo.vespa.hosted.controller.application.DeploymentJobs.JobReport) ApplicationList(com.yahoo.vespa.hosted.controller.application.ApplicationList) JobList(com.yahoo.vespa.hosted.controller.application.JobList) Change(com.yahoo.vespa.hosted.controller.application.Change) Duration(java.time.Duration) JobStatus(com.yahoo.vespa.hosted.controller.application.JobStatus) Application(com.yahoo.vespa.hosted.controller.Application) LockedApplication(com.yahoo.vespa.hosted.controller.LockedApplication) ApplicationController(com.yahoo.vespa.hosted.controller.ApplicationController) Collection(java.util.Collection) ApplicationVersion(com.yahoo.vespa.hosted.controller.application.ApplicationVersion) CuratorDb(com.yahoo.vespa.hosted.controller.persistence.CuratorDb) Instant(java.time.Instant) Logger(java.util.logging.Logger) JobError(com.yahoo.vespa.hosted.controller.application.DeploymentJobs.JobError) Objects(java.util.Objects) JobType(com.yahoo.vespa.hosted.controller.application.DeploymentJobs.JobType) List(java.util.List) Stream(java.util.stream.Stream) SystemName(com.yahoo.config.provision.SystemName) Clock(java.time.Clock) Optional(java.util.Optional) Deployment(com.yahoo.vespa.hosted.controller.application.Deployment) Collections(java.util.Collections) Controller(com.yahoo.vespa.hosted.controller.Controller) Deployment(com.yahoo.vespa.hosted.controller.application.Deployment)

Example 69 with Version

use of com.yahoo.component.Version in project vespa by vespa-engine.

the class DeploymentTrigger method triggerReadyJobs.

// --- End of methods which triggers deployment jobs ----------------------------
/**
 * Find the next step to trigger if any, and triggers it
 */
private void triggerReadyJobs(LockedApplication application) {
    List<JobType> jobs = order.jobsFrom(application.deploymentSpec());
    // Should the first step be triggered?
    if (!jobs.isEmpty() && jobs.get(0).equals(JobType.systemTest)) {
        JobStatus systemTestStatus = application.deploymentJobs().jobStatus().get(JobType.systemTest);
        if (application.change().platform().isPresent()) {
            Version target = application.change().platform().get();
            if (systemTestStatus == null || !systemTestStatus.lastTriggered().isPresent() || !systemTestStatus.isSuccess() || !systemTestStatus.lastTriggered().get().version().equals(target) || systemTestStatus.isHanging(jobTimeoutLimit())) {
                application = trigger(new Triggering(application, JobType.systemTest, false, "Upgrade to " + target), Collections.emptySet(), false);
                applications().store(application);
            }
        }
    }
    // Find next steps to trigger based on the state of the previous step
    for (JobType jobType : (Iterable<JobType>) Stream.concat(Stream.of(JobType.component), jobs.stream())::iterator) {
        JobStatus jobStatus = application.deploymentJobs().jobStatus().get(jobType);
        // job has never run
        if (jobStatus == null)
            continue;
        // Collect the subset of next jobs which have not run with the last changes
        // TODO jvenstad: Change to be step-centric.
        List<JobType> nextJobs = order.nextAfter(jobType, application);
        for (JobType nextJobType : nextJobs) {
            JobStatus nextStatus = application.deploymentJobs().jobStatus().get(nextJobType);
            if (changesAvailable(application, jobStatus, nextStatus) || nextStatus.isHanging(jobTimeoutLimit())) {
                boolean isRetry = nextStatus != null && nextStatus.jobError().filter(JobError.outOfCapacity::equals).isPresent();
                application = trigger(new Triggering(application, nextJobType, isRetry, isRetry ? "Retrying on out of capacity" : "Available change in " + jobType.jobName()), nextJobs, false);
            }
        }
        applications().store(application);
    }
}
Also used : JobStatus(com.yahoo.vespa.hosted.controller.application.JobStatus) JobType(com.yahoo.vespa.hosted.controller.application.DeploymentJobs.JobType) Version(com.yahoo.component.Version) ApplicationVersion(com.yahoo.vespa.hosted.controller.application.ApplicationVersion)

Example 70 with Version

use of com.yahoo.component.Version in project vespa by vespa-engine.

the class DeploymentIssueReporter method maintainPlatformIssue.

/**
 * When the confidence for the system version is BROKEN, file an issue listing the
 * applications that have been failing the upgrade to the system version for
 * longer than the set grace period, or update this list if the issue already exists.
 */
private void maintainPlatformIssue(List<Application> applications) {
    Version systemVersion = controller().systemVersion();
    if ((controller().versionStatus().version(systemVersion).confidence() != broken))
        return;
    if (ApplicationList.from(applications).failingUpgradeToVersionSince(systemVersion, controller().clock().instant().minus(upgradeGracePeriod)).isEmpty())
        return;
    List<ApplicationId> failingApplications = ApplicationList.from(applications).failingUpgradeToVersionSince(systemVersion, controller().clock().instant()).idList();
    deploymentIssues.fileUnlessOpen(failingApplications, systemVersion);
}
Also used : Version(com.yahoo.component.Version) ApplicationId(com.yahoo.config.provision.ApplicationId)

Aggregations

Version (com.yahoo.component.Version)83 Test (org.junit.Test)46 Application (com.yahoo.vespa.hosted.controller.Application)32 JobType.systemTest (com.yahoo.vespa.hosted.controller.application.DeploymentJobs.JobType.systemTest)30 ApplicationPackage (com.yahoo.vespa.hosted.controller.application.ApplicationPackage)25 JobType.stagingTest (com.yahoo.vespa.hosted.controller.application.DeploymentJobs.JobType.stagingTest)25 DeploymentTester (com.yahoo.vespa.hosted.controller.deployment.DeploymentTester)24 VespaVersion (com.yahoo.vespa.hosted.controller.versions.VespaVersion)22 ApplicationPackageBuilder (com.yahoo.vespa.hosted.controller.deployment.ApplicationPackageBuilder)17 ApplicationVersion (com.yahoo.vespa.hosted.controller.application.ApplicationVersion)15 ApplicationId (com.yahoo.config.provision.ApplicationId)11 Collections (java.util.Collections)11 List (java.util.List)11 Deployment (com.yahoo.vespa.hosted.controller.application.Deployment)10 Optional (java.util.Optional)10 Slime (com.yahoo.slime.Slime)9 Map (java.util.Map)9 ControllerTester (com.yahoo.vespa.hosted.controller.ControllerTester)7 ZoneId (com.yahoo.vespa.hosted.controller.api.integration.zone.ZoneId)7 URI (java.net.URI)7