use of com.yahoo.vespa.hosted.controller.restapi.MessageResponse in project vespa by vespa-engine.
the class ApplicationApiHandler method setGlobalRotationOverride.
private HttpResponse setGlobalRotationOverride(String tenantName, String applicationName, String instanceName, String environment, String region, boolean inService, HttpRequest request) {
// Check if request is authorized
Optional<Tenant> existingTenant = controller.tenants().tenant(new TenantId(tenantName));
if (!existingTenant.isPresent())
return ErrorResponse.notFoundError("Tenant '" + tenantName + "' does not exist");
// Decode payload (reason) and construct parameter to the configserver
Inspector requestData = toSlime(request.getData()).get();
String reason = mandatory("reason", requestData).asString();
String agent = getUserPrincipal(request).getIdentity().getFullName();
long timestamp = controller.clock().instant().getEpochSecond();
EndpointStatus.Status status = inService ? EndpointStatus.Status.in : EndpointStatus.Status.out;
EndpointStatus endPointStatus = new EndpointStatus(status, reason, agent, timestamp);
// DeploymentId identifies the zone and application we are dealing with
DeploymentId deploymentId = new DeploymentId(ApplicationId.from(tenantName, applicationName, instanceName), ZoneId.from(environment, region));
try {
List<String> rotations = controller.applications().setGlobalRotationStatus(deploymentId, endPointStatus);
return new MessageResponse(String.format("Rotations %s successfully set to %s service", rotations.toString(), inService ? "in" : "out of"));
} catch (IOException e) {
return ErrorResponse.internalServerError("Unable to alter rotation status: " + e.getMessage());
}
}
use of com.yahoo.vespa.hosted.controller.restapi.MessageResponse 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);
}
Aggregations