Search in sources :

Example 1 with ZoneId

use of com.yahoo.vespa.hosted.controller.api.integration.zone.ZoneId in project vespa by vespa-engine.

the class VersionStatus method findConfigServerVersions.

private static ListMap<Version, String> findConfigServerVersions(Controller controller) {
    List<URI> configServers = controller.zoneRegistry().zones().controllerManaged().not().among(ZoneId.from("prod.cd-us-east-1a"), ZoneId.from("prod.aws-us-east-1a")).ids().stream().flatMap(zoneId -> controller.zoneRegistry().getConfigServerUris(zoneId).stream()).collect(Collectors.toList());
    ListMap<Version, String> versions = new ListMap<>();
    for (URI configServer : configServers) versions.put(controller.applications().configServer().version(configServer), configServer.getHost());
    return versions;
}
Also used : JobError.outOfCapacity(com.yahoo.vespa.hosted.controller.application.DeploymentJobs.JobError.outOfCapacity) Version(com.yahoo.component.Version) Vtag(com.yahoo.component.Vtag) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) Level(java.util.logging.Level) ApplicationList(com.yahoo.vespa.hosted.controller.application.ApplicationList) HashSet(java.util.HashSet) ZoneId(com.yahoo.vespa.hosted.controller.api.integration.zone.ZoneId) ImmutableList(com.google.common.collect.ImmutableList) JobList(com.yahoo.vespa.hosted.controller.application.JobList) Map(java.util.Map) URI(java.net.URI) Application(com.yahoo.vespa.hosted.controller.Application) Collection(java.util.Collection) Set(java.util.Set) Instant(java.time.Instant) Logger(java.util.logging.Logger) Collectors(java.util.stream.Collectors) GitSha(com.yahoo.vespa.hosted.controller.api.integration.github.GitSha) List(java.util.List) Optional(java.util.Optional) Deployment(com.yahoo.vespa.hosted.controller.application.Deployment) Collections(java.util.Collections) ListMap(com.yahoo.collections.ListMap) Controller(com.yahoo.vespa.hosted.controller.Controller) Version(com.yahoo.component.Version) URI(java.net.URI) ListMap(com.yahoo.collections.ListMap)

Example 2 with ZoneId

use of com.yahoo.vespa.hosted.controller.api.integration.zone.ZoneId in project vespa by vespa-engine.

the class ControllerTest method testDeployWithoutProjectId.

@Test
public void testDeployWithoutProjectId() {
    DeploymentTester tester = new DeploymentTester();
    tester.controllerTester().zoneRegistry().setSystem(SystemName.cd);
    tester.controllerTester().zoneRegistry().setZones(ZoneId.from("prod", "cd-us-central-1"));
    ApplicationPackage applicationPackage = new ApplicationPackageBuilder().environment(Environment.prod).region("cd-us-central-1").build();
    // Create application
    Application app = tester.createApplication("app1", "tenant1", 1, 2L);
    // Direct deploy is allowed when project ID is missing
    ZoneId zone = ZoneId.from("prod", "cd-us-central-1");
    // Same options as used in our integration tests
    DeployOptions options = new DeployOptions(Optional.empty(), Optional.empty(), false, false);
    tester.controller().applications().deployApplication(app.id(), zone, Optional.of(applicationPackage), options);
    assertTrue("Application deployed and activated", tester.controllerTester().configServer().activated().getOrDefault(app.id(), false));
    assertTrue("No job status added", tester.applications().require(app.id()).deploymentJobs().jobStatus().isEmpty());
}
Also used : DeployOptions(com.yahoo.vespa.hosted.controller.api.application.v4.model.DeployOptions) ZoneId(com.yahoo.vespa.hosted.controller.api.integration.zone.ZoneId) DeploymentTester(com.yahoo.vespa.hosted.controller.deployment.DeploymentTester) ApplicationPackageBuilder(com.yahoo.vespa.hosted.controller.deployment.ApplicationPackageBuilder) ApplicationPackage(com.yahoo.vespa.hosted.controller.application.ApplicationPackage) JobType.stagingTest(com.yahoo.vespa.hosted.controller.application.DeploymentJobs.JobType.stagingTest) JobType.systemTest(com.yahoo.vespa.hosted.controller.application.DeploymentJobs.JobType.systemTest) Test(org.junit.Test)

Example 3 with ZoneId

use of com.yahoo.vespa.hosted.controller.api.integration.zone.ZoneId in project vespa by vespa-engine.

the class ControllerTest method testGlobalRotations.

@Test
public void testGlobalRotations() throws IOException {
    // Setup tester and app def
    ControllerTester tester = new ControllerTester();
    ZoneId zone = ZoneId.from(Environment.defaultEnvironment(), RegionName.defaultName());
    ApplicationId appId = ApplicationId.from("tenant", "app1", "default");
    DeploymentId deployId = new DeploymentId(appId, zone);
    // Check initial rotation status
    Map<String, EndpointStatus> rotationStatus = tester.controller().applications().getGlobalRotationStatus(deployId);
    assertEquals(1, rotationStatus.size());
    assertTrue(rotationStatus.get("qrs-endpoint").getStatus().equals(EndpointStatus.Status.in));
    // Set the global rotations out of service
    EndpointStatus status = new EndpointStatus(EndpointStatus.Status.out, "Testing I said", "Test", tester.clock().instant().getEpochSecond());
    List<String> overrides = tester.controller().applications().setGlobalRotationStatus(deployId, status);
    assertEquals(1, overrides.size());
    // Recheck the override rotation status
    rotationStatus = tester.controller().applications().getGlobalRotationStatus(deployId);
    assertEquals(1, rotationStatus.size());
    assertTrue(rotationStatus.get("qrs-endpoint").getStatus().equals(EndpointStatus.Status.out));
    assertTrue(rotationStatus.get("qrs-endpoint").getReason().equals("Testing I said"));
}
Also used : EndpointStatus(com.yahoo.vespa.hosted.controller.api.application.v4.model.EndpointStatus) DeploymentId(com.yahoo.vespa.hosted.controller.api.identifiers.DeploymentId) ZoneId(com.yahoo.vespa.hosted.controller.api.integration.zone.ZoneId) ApplicationId(com.yahoo.config.provision.ApplicationId) JobType.stagingTest(com.yahoo.vespa.hosted.controller.application.DeploymentJobs.JobType.stagingTest) JobType.systemTest(com.yahoo.vespa.hosted.controller.application.DeploymentJobs.JobType.systemTest) Test(org.junit.Test)

Example 4 with ZoneId

use of com.yahoo.vespa.hosted.controller.api.integration.zone.ZoneId 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 5 with ZoneId

use of com.yahoo.vespa.hosted.controller.api.integration.zone.ZoneId in project vespa by vespa-engine.

the class ClusterInfoMaintainer method getClusterInfo.

private Map<ClusterSpec.Id, ClusterInfo> getClusterInfo(NodeList nodes, ZoneId zone) {
    Map<ClusterSpec.Id, ClusterInfo> infoMap = new HashMap<>();
    // Group nodes by clusterid
    Map<String, List<NodeRepositoryNode>> clusters = nodes.nodes().stream().filter(node -> node.getMembership() != null).collect(Collectors.groupingBy(ClusterInfoMaintainer::clusterid));
    // For each cluster - get info
    for (String id : clusters.keySet()) {
        List<NodeRepositoryNode> clusterNodes = clusters.get(id);
        // Assume they are all equal and use first node as a representative for the cluster
        NodeRepositoryNode node = clusterNodes.get(0);
        // Extract flavor info
        double cpu = 0;
        double mem = 0;
        double disk = 0;
        // TODO: This code was never run. Reenable when flavours are available from a FlavorRegistry or something, or remove.
        /*if (zone.nodeFlavors().isPresent()) {
                Optional<Flavor> flavorOptional = zone.nodeFlavors().get().getFlavor(node.flavor);
                if ((flavorOptional.isPresent())) {
                    Flavor flavor = flavorOptional.get();
                    cpu = flavor.getMinCpuCores();
                    mem = flavor.getMinMainMemoryAvailableGb();
                    disk = flavor.getMinMainMemoryAvailableGb();
                }
            }*/
        // Add to map
        List<String> hostnames = clusterNodes.stream().map(NodeRepositoryNode::getHostname).collect(Collectors.toList());
        ClusterInfo inf = new ClusterInfo(node.getFlavor(), node.getCost(), cpu, mem, disk, ClusterSpec.Type.from(node.getMembership().clustertype), hostnames);
        infoMap.put(new ClusterSpec.Id(id), inf);
    }
    return infoMap;
}
Also used : NodeRepositoryNode(com.yahoo.vespa.hosted.controller.api.integration.noderepository.NodeRepositoryNode) DeploymentId(com.yahoo.vespa.hosted.controller.api.identifiers.DeploymentId) ClusterSpec(com.yahoo.config.provision.ClusterSpec) IOException(java.io.IOException) HashMap(java.util.HashMap) Logger(java.util.logging.Logger) Collectors(java.util.stream.Collectors) Level(java.util.logging.Level) ApplicationList(com.yahoo.vespa.hosted.controller.application.ApplicationList) List(java.util.List) ZoneId(com.yahoo.vespa.hosted.controller.api.integration.zone.ZoneId) Duration(java.time.Duration) Map(java.util.Map) ClusterInfo(com.yahoo.vespa.hosted.controller.application.ClusterInfo) Deployment(com.yahoo.vespa.hosted.controller.application.Deployment) NodeList(com.yahoo.vespa.hosted.controller.api.integration.noderepository.NodeList) Application(com.yahoo.vespa.hosted.controller.Application) Controller(com.yahoo.vespa.hosted.controller.Controller) HashMap(java.util.HashMap) NodeRepositoryNode(com.yahoo.vespa.hosted.controller.api.integration.noderepository.NodeRepositoryNode) ClusterSpec(com.yahoo.config.provision.ClusterSpec) ClusterInfo(com.yahoo.vespa.hosted.controller.application.ClusterInfo) ApplicationList(com.yahoo.vespa.hosted.controller.application.ApplicationList) List(java.util.List) NodeList(com.yahoo.vespa.hosted.controller.api.integration.noderepository.NodeList) DeploymentId(com.yahoo.vespa.hosted.controller.api.identifiers.DeploymentId) ZoneId(com.yahoo.vespa.hosted.controller.api.integration.zone.ZoneId)

Aggregations

ZoneId (com.yahoo.vespa.hosted.controller.api.integration.zone.ZoneId)13 ApplicationId (com.yahoo.config.provision.ApplicationId)4 DeployOptions (com.yahoo.vespa.hosted.controller.api.application.v4.model.DeployOptions)4 Application (com.yahoo.vespa.hosted.controller.Application)3 DeploymentId (com.yahoo.vespa.hosted.controller.api.identifiers.DeploymentId)3 Deployment (com.yahoo.vespa.hosted.controller.application.Deployment)3 HashMap (java.util.HashMap)3 Map (java.util.Map)3 ImmutableList (com.google.common.collect.ImmutableList)2 Version (com.yahoo.component.Version)2 ClusterSpec (com.yahoo.config.provision.ClusterSpec)2 Controller (com.yahoo.vespa.hosted.controller.Controller)2 ActivateResult (com.yahoo.vespa.hosted.controller.api.ActivateResult)2 EndpointStatus (com.yahoo.vespa.hosted.controller.api.application.v4.model.EndpointStatus)2 ApplicationList (com.yahoo.vespa.hosted.controller.application.ApplicationList)2 ApplicationPackage (com.yahoo.vespa.hosted.controller.application.ApplicationPackage)2 JobType.stagingTest (com.yahoo.vespa.hosted.controller.application.DeploymentJobs.JobType.stagingTest)2 JobType.systemTest (com.yahoo.vespa.hosted.controller.application.DeploymentJobs.JobType.systemTest)2 IOException (java.io.IOException)2 URI (java.net.URI)2