Search in sources :

Example 6 with Deployment

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

the class ApplicationApiHandler method deactivate.

private HttpResponse deactivate(String tenantName, String applicationName, String instanceName, String environment, String region, HttpRequest request) {
    Application application = controller.applications().require(ApplicationId.from(tenantName, applicationName, instanceName));
    ZoneId zone = ZoneId.from(environment, region);
    Deployment deployment = application.deployments().get(zone);
    if (deployment == null) {
        // Attempt to deactivate application even if the deployment is not known by the controller
        controller.applications().deactivate(application, zone);
    } else {
        controller.applications().deactivate(application, deployment, false);
    }
    // TODO: Change to return JSON
    return new StringResponse("Deactivated " + path(TenantResource.API_PATH, tenantName, ApplicationResource.API_PATH, applicationName, EnvironmentResource.API_PATH, environment, "region", region, "instance", instanceName));
}
Also used : ZoneId(com.yahoo.vespa.hosted.controller.api.integration.zone.ZoneId) Deployment(com.yahoo.vespa.hosted.controller.application.Deployment) StringResponse(com.yahoo.vespa.hosted.controller.restapi.StringResponse) Application(com.yahoo.vespa.hosted.controller.Application)

Example 7 with Deployment

use of com.yahoo.vespa.hosted.controller.application.Deployment 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);
}
Also used : DeploymentId(com.yahoo.vespa.hosted.controller.api.identifiers.DeploymentId) SlimeJsonResponse(com.yahoo.vespa.hosted.controller.restapi.SlimeJsonResponse) NotExistsException(com.yahoo.vespa.hosted.controller.NotExistsException) Deployment(com.yahoo.vespa.hosted.controller.application.Deployment) ApplicationId(com.yahoo.config.provision.ApplicationId) Slime(com.yahoo.slime.Slime) Application(com.yahoo.vespa.hosted.controller.Application)

Example 8 with Deployment

use of com.yahoo.vespa.hosted.controller.application.Deployment 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);
}
Also used : Deployment(com.yahoo.vespa.hosted.controller.application.Deployment) Change(com.yahoo.vespa.hosted.controller.application.Change) DeploymentSpec(com.yahoo.config.application.api.DeploymentSpec) DeploymentJobs(com.yahoo.vespa.hosted.controller.application.DeploymentJobs) Inspector(com.yahoo.slime.Inspector) IssueId(com.yahoo.vespa.hosted.controller.api.integration.organization.IssueId) ApplicationId(com.yahoo.config.provision.ApplicationId) ValidationOverrides(com.yahoo.config.application.api.ValidationOverrides) ApplicationMetrics(com.yahoo.vespa.hosted.controller.api.integration.MetricsService.ApplicationMetrics) RotationId(com.yahoo.vespa.hosted.controller.rotation.RotationId) Application(com.yahoo.vespa.hosted.controller.Application)

Example 9 with Deployment

use of com.yahoo.vespa.hosted.controller.application.Deployment 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)));
        }
    }
}
Also used : Deployment(com.yahoo.vespa.hosted.controller.application.Deployment) ClusterUtilization(com.yahoo.vespa.hosted.controller.application.ClusterUtilization) ZoneId(com.yahoo.vespa.hosted.controller.api.integration.zone.ZoneId) ApplicationId(com.yahoo.config.provision.ApplicationId) Application(com.yahoo.vespa.hosted.controller.Application)

Example 10 with Deployment

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

the class ApplicationController method deleteRemovedDeployments.

private LockedApplication deleteRemovedDeployments(LockedApplication application) {
    List<Deployment> deploymentsToRemove = application.productionDeployments().values().stream().filter(deployment -> !application.deploymentSpec().includes(deployment.zone().environment(), Optional.of(deployment.zone().region()))).collect(Collectors.toList());
    if (deploymentsToRemove.isEmpty())
        return application;
    if (!application.validationOverrides().allows(ValidationId.deploymentRemoval, clock.instant()))
        throw new IllegalArgumentException(ValidationId.deploymentRemoval.value() + ": " + application + " is deployed in " + deploymentsToRemove.stream().map(deployment -> deployment.zone().region().value()).collect(Collectors.joining(", ")) + ", but does not include " + (deploymentsToRemove.size() > 1 ? "these zones" : "this zone") + " in deployment.xml");
    LockedApplication applicationWithRemoval = application;
    for (Deployment deployment : deploymentsToRemove) applicationWithRemoval = deactivate(applicationWithRemoval, deployment.zone());
    return applicationWithRemoval;
}
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) Deployment(com.yahoo.vespa.hosted.controller.application.Deployment)

Aggregations

Deployment (com.yahoo.vespa.hosted.controller.application.Deployment)21 Application (com.yahoo.vespa.hosted.controller.Application)15 ApplicationId (com.yahoo.config.provision.ApplicationId)12 Version (com.yahoo.component.Version)9 ZoneId (com.yahoo.vespa.hosted.controller.api.integration.zone.ZoneId)9 ApplicationVersion (com.yahoo.vespa.hosted.controller.application.ApplicationVersion)7 DeploymentSpec (com.yahoo.config.application.api.DeploymentSpec)6 DeploymentId (com.yahoo.vespa.hosted.controller.api.identifiers.DeploymentId)6 ApplicationPackage (com.yahoo.vespa.hosted.controller.application.ApplicationPackage)6 DeploymentJobs (com.yahoo.vespa.hosted.controller.application.DeploymentJobs)6 Collections (java.util.Collections)6 List (java.util.List)6 Optional (java.util.Optional)6 ControllerTester (com.yahoo.vespa.hosted.controller.ControllerTester)5 DeploymentMetrics (com.yahoo.vespa.hosted.controller.application.DeploymentMetrics)5 URI (java.net.URI)5 ArrayList (java.util.ArrayList)5 Environment (com.yahoo.config.provision.Environment)4 TenantName (com.yahoo.config.provision.TenantName)4 JobStatus (com.yahoo.vespa.hosted.controller.application.JobStatus)4