use of com.yahoo.vespa.hosted.controller.Application in project vespa by vespa-engine.
the class ApplicationApiHandler method deployment.
private HttpResponse deployment(String tenantName, String applicationName, String instanceName, String environment, String region, HttpRequest request) {
ApplicationId id = ApplicationId.from(tenantName, applicationName, instanceName);
Application application = controller.applications().get(id).orElseThrow(() -> new NotExistsException(id + " not found"));
DeploymentId deploymentId = new DeploymentId(application.id(), ZoneId.from(environment, region));
Deployment deployment = application.deployments().get(deploymentId.zoneId());
if (deployment == null)
throw new NotExistsException(application + " is not deployed in " + deploymentId.zoneId());
Slime slime = new Slime();
toSlime(slime.setObject(), deploymentId, deployment, request);
return new SlimeJsonResponse(slime);
}
use of com.yahoo.vespa.hosted.controller.Application in project vespa by vespa-engine.
the class Upgrader method upgrade.
private void upgrade(ApplicationList applications, Version version) {
// Pull requests are deployed as separate applications to test then deleted; No need to upgrade
applications = applications.notPullRequest();
applications = applications.hasProductionDeployment();
applications = applications.onLowerVersionThan(version);
// wait with applications deploying an application change or already upgrading
applications = applications.notDeploying();
// try to upgrade only if it hasn't failed on this version
applications = applications.notFailingOn(version);
// wait with applications that are currently blocking upgrades
applications = applications.canUpgradeAt(controller().clock().instant());
// start with lowest versions
applications = applications.byIncreasingDeployedVersion();
// throttle upgrades
applications = applications.first(numberOfApplicationsToUpgrade());
for (Application application : applications.asList()) {
try {
controller().applications().deploymentTrigger().triggerChange(application.id(), Change.of(version));
} catch (IllegalArgumentException e) {
log.log(Level.INFO, "Could not trigger change: " + Exceptions.toMessageString(e));
}
}
}
use of com.yahoo.vespa.hosted.controller.Application in project vespa by vespa-engine.
the class ApplicationSerializer method fromSlime.
// ------------------ Deserialization
public Application fromSlime(Slime slime) {
Inspector root = slime.get();
ApplicationId id = ApplicationId.fromSerializedForm(root.field(idField).asString());
DeploymentSpec deploymentSpec = DeploymentSpec.fromXml(root.field(deploymentSpecField).asString(), false);
ValidationOverrides validationOverrides = ValidationOverrides.fromXml(root.field(validationOverridesField).asString());
List<Deployment> deployments = deploymentsFromSlime(root.field(deploymentsField));
DeploymentJobs deploymentJobs = deploymentJobsFromSlime(root.field(deploymentJobsField));
Change deploying = changeFromSlime(root.field(deployingField));
Change outstandingChange = changeFromSlime(root.field(outstandingChangeField));
Optional<IssueId> ownershipIssueId = optionalString(root.field(ownershipIssueIdField)).map(IssueId::from);
ApplicationMetrics metrics = new ApplicationMetrics(root.field(queryQualityField).asDouble(), root.field(writeQualityField).asDouble());
Optional<RotationId> rotation = rotationFromSlime(root.field(rotationField));
return new Application(id, deploymentSpec, validationOverrides, deployments, deploymentJobs, deploying, outstandingChange, ownershipIssueId, metrics, rotation);
}
use of com.yahoo.vespa.hosted.controller.Application in project vespa by vespa-engine.
the class ClusterUtilizationMaintainer method maintain.
@Override
protected void maintain() {
for (Application application : ApplicationList.from(controller().applications().asList()).notPullRequest().asList()) {
for (Deployment deployment : application.deployments().values()) {
Map<ClusterSpec.Id, ClusterUtilization> clusterUtilization = getUpdatedClusterUtilizations(application.id(), deployment.zone());
controller().applications().lockIfPresent(application.id(), lockedApplication -> controller().applications().store(lockedApplication.withClusterUtilization(deployment.zone(), clusterUtilization)));
}
}
}
use of com.yahoo.vespa.hosted.controller.Application 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());
}
Aggregations