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;
}
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());
}
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"));
}
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));
}
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;
}
Aggregations