use of com.yahoo.vespa.hosted.controller.application.Change in project vespa by vespa-engine.
the class ApplicationApiHandler method cancelDeploy.
/**
* Cancel any ongoing change for given application
*/
// TODO Consider move to API for maintenance related operations
private HttpResponse cancelDeploy(String tenantName, String applicationName) {
ApplicationId id = ApplicationId.from(tenantName, applicationName, "default");
Application application = controller.applications().require(id);
Change change = application.change();
if (!change.isPresent())
return new MessageResponse("No deployment in progress for " + application + " at this time");
controller.applications().lockOrThrow(id, lockedApplication -> controller.applications().deploymentTrigger().cancelChange(id, false));
return new MessageResponse("Cancelled " + change + " for " + application);
}
use of com.yahoo.vespa.hosted.controller.application.Change 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.Change in project vespa by vespa-engine.
the class ApplicationApiHandler method toSlime.
private void toSlime(Cursor object, Application application, HttpRequest request) {
object.setString("application", application.id().application().value());
object.setString("instance", application.id().instance().value());
// Currently deploying change
if (application.change().isPresent()) {
Cursor deployingObject = object.setObject("deploying");
application.change().platform().ifPresent(v -> deployingObject.setString("version", v.toString()));
application.change().application().filter(v -> v != ApplicationVersion.unknown).ifPresent(v -> toSlime(v, deployingObject.setObject("revision")));
}
// Jobs sorted according to deployment spec
List<JobStatus> jobStatus = controller.applications().deploymentTrigger().deploymentOrder().sortBy(application.deploymentSpec(), application.deploymentJobs().jobStatus().values());
Cursor deploymentsArray = object.setArray("deploymentJobs");
for (JobStatus job : jobStatus) {
Cursor jobObject = deploymentsArray.addObject();
jobObject.setString("type", job.type().jobName());
jobObject.setBool("success", job.isSuccess());
job.lastTriggered().ifPresent(jobRun -> toSlime(jobRun, jobObject.setObject("lastTriggered")));
job.lastCompleted().ifPresent(jobRun -> toSlime(jobRun, jobObject.setObject("lastCompleted")));
job.firstFailing().ifPresent(jobRun -> toSlime(jobRun, jobObject.setObject("firstFailing")));
job.lastSuccess().ifPresent(jobRun -> toSlime(jobRun, jobObject.setObject("lastSuccess")));
}
// Change blockers
Cursor changeBlockers = object.setArray("changeBlockers");
application.deploymentSpec().changeBlocker().forEach(changeBlocker -> {
Cursor changeBlockerObject = changeBlockers.addObject();
changeBlockerObject.setBool("versions", changeBlocker.blocksVersions());
changeBlockerObject.setBool("revisions", changeBlocker.blocksRevisions());
changeBlockerObject.setString("timeZone", changeBlocker.window().zone().getId());
Cursor days = changeBlockerObject.setArray("days");
changeBlocker.window().days().stream().map(DayOfWeek::getValue).forEach(days::addLong);
Cursor hours = changeBlockerObject.setArray("hours");
changeBlocker.window().hours().forEach(hours::addLong);
});
// Compile version. The version that should be used when building an application
object.setString("compileVersion", application.oldestDeployedVersion().orElse(controller.systemVersion()).toFullString());
// Rotation
Cursor globalRotationsArray = object.setArray("globalRotations");
application.rotation().ifPresent(rotation -> {
globalRotationsArray.addString(rotation.url().toString());
globalRotationsArray.addString(rotation.secureUrl().toString());
object.setString("rotationId", rotation.id().asString());
});
// Deployments sorted according to deployment spec
List<Deployment> deployments = controller.applications().deploymentTrigger().deploymentOrder().sortBy(application.deploymentSpec().zones(), application.deployments().values());
Cursor instancesArray = object.setArray("instances");
for (Deployment deployment : deployments) {
Cursor deploymentObject = instancesArray.addObject();
deploymentObject.setString("environment", deployment.zone().environment().value());
deploymentObject.setString("region", deployment.zone().region().value());
// pointless
deploymentObject.setString("instance", application.id().instance().value());
if (application.rotation().isPresent()) {
Map<String, RotationStatus> rotationHealthStatus = application.rotation().map(rotation -> controller.getHealthStatus(rotation.dnsName())).orElse(Collections.emptyMap());
setRotationStatus(deployment, rotationHealthStatus, deploymentObject);
}
if (// List full deployment information when recursive.
recurseOverDeployments(request))
toSlime(deploymentObject, new DeploymentId(application.id(), deployment.zone()), deployment, request);
else
deploymentObject.setString("url", withPath(request.getUri().getPath() + "/environment/" + deployment.zone().environment().value() + "/region/" + deployment.zone().region().value() + "/instance/" + application.id().instance().value(), request.getUri()).toString());
}
// Metrics
Cursor metricsObject = object.setObject("metrics");
metricsObject.setDouble("queryServiceQuality", application.metrics().queryServiceQuality());
metricsObject.setDouble("writeServiceQuality", application.metrics().writeServiceQuality());
application.ownershipIssueId().ifPresent(issueId -> object.setString("ownershipIssueId", issueId.value()));
application.deploymentJobs().issueId().ifPresent(issueId -> object.setString("deploymentIssueId", issueId.value()));
}
use of com.yahoo.vespa.hosted.controller.application.Change in project vespa by vespa-engine.
the class DeploymentTester method completeDeployment.
private void completeDeployment(Application application, ApplicationPackage applicationPackage, Optional<JobType> failOnJob, boolean includingProductionZones) {
DeploymentOrder order = new DeploymentOrder(controller());
List<JobType> jobs = order.jobsFrom(applicationPackage.deploymentSpec());
if (!includingProductionZones)
jobs = jobs.stream().filter(job -> !job.isProduction()).collect(Collectors.toList());
for (JobType job : jobs) {
boolean failJob = failOnJob.map(j -> j.equals(job)).orElse(false);
deployAndNotify(application, applicationPackage, !failJob, false, job);
if (failJob) {
break;
}
}
if (failOnJob.isPresent()) {
assertTrue(applications().require(application.id()).change().isPresent());
assertTrue(applications().require(application.id()).deploymentJobs().hasFailures());
} else if (includingProductionZones) {
assertFalse(applications().require(application.id()).change().isPresent());
} else {
assertTrue(applications().require(application.id()).change().isPresent());
}
}
use of com.yahoo.vespa.hosted.controller.application.Change 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;
}
Aggregations