Search in sources :

Example 26 with ApplicationPackage

use of com.yahoo.vespa.hosted.controller.application.ApplicationPackage in project vespa by vespa-engine.

the class ApplicationApiHandler method deploy.

private HttpResponse deploy(String tenantName, String applicationName, String instanceName, String environment, String region, HttpRequest request) {
    ApplicationId applicationId = ApplicationId.from(tenantName, applicationName, instanceName);
    ZoneId zone = ZoneId.from(environment, region);
    Map<String, byte[]> dataParts = new MultipartParser().parse(request);
    if (!dataParts.containsKey("deployOptions"))
        return ErrorResponse.badRequest("Missing required form part 'deployOptions'");
    Inspector deployOptions = SlimeUtils.jsonToSlime(dataParts.get("deployOptions")).get();
    Optional<ApplicationPackage> applicationPackage = Optional.ofNullable(dataParts.get("applicationZip")).map(ApplicationPackage::new);
    verifyApplicationIdentityConfiguration(tenantName, applicationPackage);
    // TODO: get rid of the json object
    DeployOptions deployOptionsJsonClass = new DeployOptions(screwdriverBuildJobFromSlime(deployOptions.field("screwdriverBuildJob")), optional("vespaVersion", deployOptions).map(Version::new), deployOptions.field("ignoreValidationErrors").asBool(), deployOptions.field("deployCurrentVersion").asBool());
    ActivateResult result = controller.applications().deployApplication(applicationId, zone, applicationPackage, deployOptionsJsonClass);
    return new SlimeJsonResponse(toSlime(result));
}
Also used : DeployOptions(com.yahoo.vespa.hosted.controller.api.application.v4.model.DeployOptions) ActivateResult(com.yahoo.vespa.hosted.controller.api.ActivateResult) SlimeJsonResponse(com.yahoo.vespa.hosted.controller.restapi.SlimeJsonResponse) ZoneId(com.yahoo.vespa.hosted.controller.api.integration.zone.ZoneId) Inspector(com.yahoo.slime.Inspector) ApplicationId(com.yahoo.config.provision.ApplicationId) ApplicationPackage(com.yahoo.vespa.hosted.controller.application.ApplicationPackage)

Example 27 with ApplicationPackage

use of com.yahoo.vespa.hosted.controller.application.ApplicationPackage in project vespa by vespa-engine.

the class ApplicationController method artifactFor.

/**
 * Decide application package and version pair to use in given zone
 */
private Pair<ApplicationPackage, ApplicationVersion> artifactFor(ZoneId zone, Application application, Optional<ApplicationPackage> applicationPackage, boolean canDeployDirectly, boolean deployCurrentVersion) {
    ApplicationVersion version;
    ApplicationPackage pkg;
    Optional<DeploymentJobs.JobType> job = DeploymentJobs.JobType.from(controller.system(), zone);
    if (canDeployDirectly) {
        pkg = applicationPackage.orElseThrow(() -> new IllegalArgumentException("Application package must be " + "given when deploying to " + zone));
        version = ApplicationVersion.unknown;
    } else {
        if (!job.isPresent()) {
            throw new IllegalArgumentException("No job found for zone " + zone);
        }
        version = application.deployApplicationVersionFor(job.get(), controller, deployCurrentVersion).orElseThrow(() -> new IllegalArgumentException("Cannot determine application version to use for " + job.get()));
        pkg = new ApplicationPackage(artifactRepository.getApplicationPackage(application.id(), version.id()));
    }
    return new Pair<>(pkg, version);
}
Also used : ApplicationVersion(com.yahoo.vespa.hosted.controller.application.ApplicationVersion) ApplicationPackage(com.yahoo.vespa.hosted.controller.application.ApplicationPackage) Pair(com.yahoo.collections.Pair)

Example 28 with ApplicationPackage

use of com.yahoo.vespa.hosted.controller.application.ApplicationPackage in project vespa by vespa-engine.

the class DeploymentTriggerTest method testBlockRevisionChange.

@Test
public void testBlockRevisionChange() {
    // Tuesday, 17:30
    ManualClock clock = new ManualClock(Instant.parse("2017-09-26T17:30:00.00Z"));
    DeploymentTester tester = new DeploymentTester(new ControllerTester(clock));
    ReadyJobsTrigger readyJobsTrigger = new ReadyJobsTrigger(tester.controller(), Duration.ofHours(1), new JobControl(tester.controllerTester().curator()));
    Version version = Version.fromString("5.0");
    tester.updateVersionStatus(version);
    ApplicationPackageBuilder applicationPackageBuilder = new ApplicationPackageBuilder().upgradePolicy("canary").blockChange(true, false, "tue", "18-19", "UTC").region("us-west-1").region("us-central-1").region("us-east-3");
    Application app = tester.createAndDeploy("app1", 1, applicationPackageBuilder.build());
    // --------------- Enter block window: 18:30
    tester.clock().advance(Duration.ofHours(1));
    readyJobsTrigger.run();
    assertEquals(0, tester.deploymentQueue().jobs().size());
    String searchDefinition = "search test {\n" + "  document test {\n" + "    field test type string {\n" + "    }\n" + "  }\n" + "}\n";
    ApplicationPackage changedApplication = applicationPackageBuilder.searchDefinition(searchDefinition).build();
    tester.jobCompletion(component).application(app).nextBuildNumber().sourceRevision(new SourceRevision("repository1", "master", "cafed00d")).uploadArtifact(changedApplication).submit();
    assertTrue(tester.applications().require(app.id()).change().isPresent());
    tester.deployAndNotify(app, changedApplication, true, systemTest);
    tester.deployAndNotify(app, changedApplication, true, stagingTest);
    readyJobsTrigger.run();
    assertEquals(0, tester.deploymentQueue().jobs().size());
    // ---------------- Exit block window: 20:30
    tester.clock().advance(Duration.ofHours(2));
    // Schedules the blocked production job(s)
    tester.deploymentTrigger().triggerReadyJobs();
    assertEquals(1, tester.deploymentQueue().jobs().size());
    BuildService.BuildJob productionJob = tester.deploymentQueue().takeJobsToRun().get(0);
    assertEquals("production-us-west-1", productionJob.jobName());
}
Also used : SourceRevision(com.yahoo.vespa.hosted.controller.application.SourceRevision) BuildService(com.yahoo.vespa.hosted.controller.api.integration.BuildService) JobControl(com.yahoo.vespa.hosted.controller.maintenance.JobControl) ReadyJobsTrigger(com.yahoo.vespa.hosted.controller.maintenance.ReadyJobsTrigger) ApplicationPackage(com.yahoo.vespa.hosted.controller.application.ApplicationPackage) ControllerTester(com.yahoo.vespa.hosted.controller.ControllerTester) ManualClock(com.yahoo.test.ManualClock) Version(com.yahoo.component.Version) ApplicationVersion(com.yahoo.vespa.hosted.controller.application.ApplicationVersion) Application(com.yahoo.vespa.hosted.controller.Application) LockedApplication(com.yahoo.vespa.hosted.controller.LockedApplication) JobType.systemTest(com.yahoo.vespa.hosted.controller.application.DeploymentJobs.JobType.systemTest) Test(org.junit.Test) JobType.stagingTest(com.yahoo.vespa.hosted.controller.application.DeploymentJobs.JobType.stagingTest)

Example 29 with ApplicationPackage

use of com.yahoo.vespa.hosted.controller.application.ApplicationPackage in project vespa by vespa-engine.

the class DeploymentTriggerTest method testHandleMultipleNotificationsFromLastJob.

@Test
public void testHandleMultipleNotificationsFromLastJob() {
    DeploymentTester tester = new DeploymentTester();
    DeploymentQueue deploymentQueue = tester.deploymentQueue();
    TenantId tenant = tester.controllerTester().createTenant("tenant1", "domain1", 1L);
    Application application = tester.controllerTester().createApplication(tenant, "app1", "default", 1L);
    ApplicationPackage applicationPackage = new ApplicationPackageBuilder().environment(Environment.prod).region("corp-us-east-1").build();
    // Component job finishes
    tester.jobCompletion(component).application(application).uploadArtifact(applicationPackage).submit();
    // Application is deployed to all test environments and declared zones
    tester.deployAndNotify(application, applicationPackage, true, JobType.systemTest);
    tester.deployAndNotify(application, applicationPackage, true, JobType.stagingTest);
    tester.deployAndNotify(application, applicationPackage, true, JobType.productionCorpUsEast1);
    // Extra notification for last job
    tester.jobCompletion(JobType.productionCorpUsEast1).application(application).submit();
    assertFalse("Change has been deployed", tester.applications().require(application.id()).change().isPresent());
    assertTrue("All jobs consumed", deploymentQueue.jobs().isEmpty());
}
Also used : TenantId(com.yahoo.vespa.hosted.controller.api.identifiers.TenantId) Application(com.yahoo.vespa.hosted.controller.Application) LockedApplication(com.yahoo.vespa.hosted.controller.LockedApplication) ApplicationPackage(com.yahoo.vespa.hosted.controller.application.ApplicationPackage) JobType.systemTest(com.yahoo.vespa.hosted.controller.application.DeploymentJobs.JobType.systemTest) Test(org.junit.Test) JobType.stagingTest(com.yahoo.vespa.hosted.controller.application.DeploymentJobs.JobType.stagingTest)

Example 30 with ApplicationPackage

use of com.yahoo.vespa.hosted.controller.application.ApplicationPackage in project vespa by vespa-engine.

the class DeploymentTriggerTest method testSuccessfulDeploymentApplicationPackageChanged.

@Test
public void testSuccessfulDeploymentApplicationPackageChanged() {
    DeploymentTester tester = new DeploymentTester();
    DeploymentQueue deploymentQueue = tester.deploymentQueue();
    TenantId tenant = tester.controllerTester().createTenant("tenant1", "domain1", 1L);
    Application application = tester.controllerTester().createApplication(tenant, "app1", "default", 1L);
    ApplicationPackage previousApplicationPackage = new ApplicationPackageBuilder().environment(Environment.prod).region("corp-us-east-1").region("us-central-1").region("us-west-1").build();
    ApplicationPackage newApplicationPackage = new ApplicationPackageBuilder().environment(Environment.prod).region("corp-us-east-1").region("us-central-1").region("us-west-1").region("eu-west-1").build();
    // Component job finishes
    tester.jobCompletion(component).application(application).uploadArtifact(newApplicationPackage).submit();
    // Application is deployed to all test environments and declared zones
    tester.deployAndNotify(application, newApplicationPackage, true, JobType.systemTest);
    tester.deploy(JobType.stagingTest, application, previousApplicationPackage, true);
    tester.deployAndNotify(application, newApplicationPackage, true, JobType.stagingTest);
    tester.deployAndNotify(application, newApplicationPackage, true, JobType.productionCorpUsEast1);
    tester.deployAndNotify(application, newApplicationPackage, true, JobType.productionUsCentral1);
    tester.deployAndNotify(application, newApplicationPackage, true, JobType.productionUsWest1);
    tester.deployAndNotify(application, newApplicationPackage, true, JobType.productionEuWest1);
    assertTrue("All jobs consumed", deploymentQueue.jobs().isEmpty());
}
Also used : TenantId(com.yahoo.vespa.hosted.controller.api.identifiers.TenantId) Application(com.yahoo.vespa.hosted.controller.Application) LockedApplication(com.yahoo.vespa.hosted.controller.LockedApplication) ApplicationPackage(com.yahoo.vespa.hosted.controller.application.ApplicationPackage) JobType.systemTest(com.yahoo.vespa.hosted.controller.application.DeploymentJobs.JobType.systemTest) Test(org.junit.Test) JobType.stagingTest(com.yahoo.vespa.hosted.controller.application.DeploymentJobs.JobType.stagingTest)

Aggregations

ApplicationPackage (com.yahoo.vespa.hosted.controller.application.ApplicationPackage)50 Test (org.junit.Test)44 Application (com.yahoo.vespa.hosted.controller.Application)37 ApplicationPackageBuilder (com.yahoo.vespa.hosted.controller.deployment.ApplicationPackageBuilder)33 JobType.systemTest (com.yahoo.vespa.hosted.controller.application.DeploymentJobs.JobType.systemTest)31 JobType.stagingTest (com.yahoo.vespa.hosted.controller.application.DeploymentJobs.JobType.stagingTest)26 Version (com.yahoo.component.Version)23 DeploymentTester (com.yahoo.vespa.hosted.controller.deployment.DeploymentTester)22 VespaVersion (com.yahoo.vespa.hosted.controller.versions.VespaVersion)11 LockedApplication (com.yahoo.vespa.hosted.controller.LockedApplication)10 ApplicationVersion (com.yahoo.vespa.hosted.controller.application.ApplicationVersion)10 TenantId (com.yahoo.vespa.hosted.controller.api.identifiers.TenantId)8 ApplicationId (com.yahoo.config.provision.ApplicationId)5 ManualClock (com.yahoo.test.ManualClock)5 ControllerTester (com.yahoo.vespa.hosted.controller.ControllerTester)5 ZoneId (com.yahoo.vespa.hosted.controller.api.integration.zone.ZoneId)5 Environment (com.yahoo.config.provision.Environment)4 DeployOptions (com.yahoo.vespa.hosted.controller.api.application.v4.model.DeployOptions)4 BuildService (com.yahoo.vespa.hosted.controller.api.integration.BuildService)4 Record (com.yahoo.vespa.hosted.controller.api.integration.dns.Record)4