use of com.yahoo.vespa.hosted.provision.Node in project vespa by vespa-engine.
the class ProvisioningTest method application_deployment_with_inplace_downsize.
// TODO: Enable when this feature is re-enabled
@Ignore
@Test
public void application_deployment_with_inplace_downsize() {
ProvisioningTester tester = new ProvisioningTester(new Zone(Environment.prod, RegionName.from("us-east")));
ApplicationId application1 = tester.makeApplicationId();
tester.makeReadyNodes(14, "dockerLarge");
// deploy
SystemState state1 = prepare(application1, 2, 2, 4, 4, "dockerLarge", tester);
tester.activate(application1, state1.allHosts);
// redeploy with smaller docker flavor - causes in-place flavor change
SystemState state2 = prepare(application1, 2, 2, 4, 4, "dockerSmall", tester);
tester.activate(application1, state2.allHosts);
assertEquals(12, tester.getNodes(application1, Node.State.active).asList().size());
for (Node node : tester.getNodes(application1, Node.State.active).asList()) assertEquals("Node changed flavor in place", "dockerSmall", node.flavor().name());
assertEquals("No nodes are retired", 0, tester.getNodes(application1, Node.State.active).retired().size());
}
use of com.yahoo.vespa.hosted.provision.Node in project vespa by vespa-engine.
the class NodeFailTester method withTwoApplicationsOnDocker.
public static NodeFailTester withTwoApplicationsOnDocker(int numberOfHosts) {
NodeFailTester tester = new NodeFailTester();
int nodesPerHost = 3;
List<Node> hosts = tester.createHostNodes(numberOfHosts);
for (int i = 0; i < hosts.size(); i++) {
tester.createReadyNodes(nodesPerHost, i * nodesPerHost, Optional.of("parent" + i), nodeFlavors.getFlavorOrThrow("docker"), NodeType.tenant);
}
// Create applications
ClusterSpec clusterNodeAdminApp = ClusterSpec.request(ClusterSpec.Type.container, ClusterSpec.Id.from("node-admin"), Version.fromString("6.42"), false);
ClusterSpec clusterApp1 = ClusterSpec.request(ClusterSpec.Type.container, ClusterSpec.Id.from("test"), Version.fromString("6.75.0"), false);
ClusterSpec clusterApp2 = ClusterSpec.request(ClusterSpec.Type.content, ClusterSpec.Id.from("test"), Version.fromString("6.75.0"), false);
Capacity allHosts = Capacity.fromRequiredNodeType(NodeType.host);
Capacity capacity1 = Capacity.fromNodeCount(3, Optional.of("docker"), false);
Capacity capacity2 = Capacity.fromNodeCount(5, Optional.of("docker"), false);
tester.activate(nodeAdminApp, clusterNodeAdminApp, allHosts);
tester.activate(app1, clusterApp1, capacity1);
tester.activate(app2, clusterApp2, capacity2);
assertEquals(new HashSet<>(tester.nodeRepository.getNodes(NodeType.host)), new HashSet<>(tester.nodeRepository.getNodes(nodeAdminApp, Node.State.active)));
assertEquals(capacity1.nodeCount(), tester.nodeRepository.getNodes(app1, Node.State.active).size());
assertEquals(capacity2.nodeCount(), tester.nodeRepository.getNodes(app2, Node.State.active).size());
Map<ApplicationId, MockDeployer.ApplicationContext> apps = new HashMap<>();
apps.put(nodeAdminApp, new MockDeployer.ApplicationContext(nodeAdminApp, clusterNodeAdminApp, allHosts, 1));
apps.put(app1, new MockDeployer.ApplicationContext(app1, clusterApp1, capacity1, 1));
apps.put(app2, new MockDeployer.ApplicationContext(app2, clusterApp2, capacity2, 1));
tester.deployer = new MockDeployer(tester.provisioner, apps);
tester.serviceMonitor = new ServiceMonitorStub(apps, tester.nodeRepository);
tester.metric = new MetricsReporterTest.TestMetric();
tester.failer = tester.createFailer();
return tester;
}
use of com.yahoo.vespa.hosted.provision.Node in project vespa by vespa-engine.
the class RetiredExpirerTest method ensure_early_inactivation.
@Test
public void ensure_early_inactivation() throws OrchestrationException {
createReadyNodes(7, nodeRepository, nodeFlavors);
createHostNodes(4, nodeRepository, nodeFlavors);
ApplicationId applicationId = ApplicationId.from(TenantName.from("foo"), ApplicationName.from("bar"), InstanceName.from("fuz"));
// Allocate content cluster of sizes 7 -> 2 -> 3:
// Should end up with 3 nodes in the cluster (one previously retired), and 4 retired
ClusterSpec cluster = ClusterSpec.request(ClusterSpec.Type.content, ClusterSpec.Id.from("test"), Version.fromString("6.42"), false);
int wantedNodes;
activate(applicationId, cluster, wantedNodes = 7, 1, provisioner);
activate(applicationId, cluster, wantedNodes = 2, 1, provisioner);
activate(applicationId, cluster, wantedNodes = 3, 1, provisioner);
assertEquals(7, nodeRepository.getNodes(applicationId, Node.State.active).size());
assertEquals(0, nodeRepository.getNodes(applicationId, Node.State.inactive).size());
// Cause inactivation of retired nodes
MockDeployer deployer = new MockDeployer(provisioner, Collections.singletonMap(applicationId, new MockDeployer.ApplicationContext(applicationId, cluster, Capacity.fromNodeCount(wantedNodes, Optional.of("default"), false), 1)));
// Allow the 1st and 3rd retired nodes permission to inactivate
doNothing().doThrow(new OrchestrationException("Permission not granted 1")).doNothing().doThrow(new OrchestrationException("Permission not granted 2")).when(orchestrator).acquirePermissionToRemove(any());
RetiredExpirer retiredExpirer = createRetiredExpirer(deployer);
retiredExpirer.run();
assertEquals(5, nodeRepository.getNodes(applicationId, Node.State.active).size());
assertEquals(2, nodeRepository.getNodes(applicationId, Node.State.inactive).size());
assertEquals(1, deployer.redeployments);
verify(orchestrator, times(4)).acquirePermissionToRemove(any());
// Running it again has no effect
retiredExpirer.run();
assertEquals(5, nodeRepository.getNodes(applicationId, Node.State.active).size());
assertEquals(2, nodeRepository.getNodes(applicationId, Node.State.inactive).size());
assertEquals(1, deployer.redeployments);
verify(orchestrator, times(6)).acquirePermissionToRemove(any());
clock.advance(RETIRED_EXPIRATION.plusMinutes(1));
retiredExpirer.run();
assertEquals(3, nodeRepository.getNodes(applicationId, Node.State.active).size());
assertEquals(4, nodeRepository.getNodes(applicationId, Node.State.inactive).size());
assertEquals(2, deployer.redeployments);
verify(orchestrator, times(6)).acquirePermissionToRemove(any());
// inactivated nodes are not retired
for (Node node : nodeRepository.getNodes(applicationId, Node.State.inactive)) assertFalse(node.allocation().get().membership().retired());
}
use of com.yahoo.vespa.hosted.provision.Node in project vespa by vespa-engine.
the class RetiredExpirerTest method ensure_retired_nodes_time_out.
@Test
public void ensure_retired_nodes_time_out() {
createReadyNodes(7, nodeRepository, nodeFlavors);
createHostNodes(4, nodeRepository, nodeFlavors);
ApplicationId applicationId = ApplicationId.from(TenantName.from("foo"), ApplicationName.from("bar"), InstanceName.from("fuz"));
// Allocate content cluster of sizes 7 -> 2 -> 3:
// Should end up with 3 nodes in the cluster (one previously retired), and 4 retired
ClusterSpec cluster = ClusterSpec.request(ClusterSpec.Type.content, ClusterSpec.Id.from("test"), Version.fromString("6.42"), false);
int wantedNodes;
activate(applicationId, cluster, wantedNodes = 7, 1, provisioner);
activate(applicationId, cluster, wantedNodes = 2, 1, provisioner);
activate(applicationId, cluster, wantedNodes = 3, 1, provisioner);
assertEquals(7, nodeRepository.getNodes(applicationId, Node.State.active).size());
assertEquals(0, nodeRepository.getNodes(applicationId, Node.State.inactive).size());
// Cause inactivation of retired nodes
// Retire period spent
clock.advance(Duration.ofHours(30));
MockDeployer deployer = new MockDeployer(provisioner, Collections.singletonMap(applicationId, new MockDeployer.ApplicationContext(applicationId, cluster, Capacity.fromNodeCount(wantedNodes, Optional.of("default"), false), 1)));
createRetiredExpirer(deployer).run();
assertEquals(3, nodeRepository.getNodes(applicationId, Node.State.active).size());
assertEquals(4, nodeRepository.getNodes(applicationId, Node.State.inactive).size());
assertEquals(1, deployer.redeployments);
// inactivated nodes are not retired
for (Node node : nodeRepository.getNodes(applicationId, Node.State.inactive)) assertFalse(node.allocation().get().membership().retired());
}
use of com.yahoo.vespa.hosted.provision.Node in project vespa by vespa-engine.
the class MetricsReporterTest method test_registered_metric.
@Test
public void test_registered_metric() throws Exception {
NodeFlavors nodeFlavors = FlavorConfigBuilder.createDummies("default");
Curator curator = new MockCurator();
NodeRepository nodeRepository = new NodeRepository(nodeFlavors, curator, Clock.systemUTC(), Zone.defaultZone(), new MockNameResolver().mockAnyLookup(), new DockerImage("docker-registry.domain.tld:8080/dist/vespa"), true);
Node node = nodeRepository.createNode("openStackId", "hostname", Optional.empty(), nodeFlavors.getFlavorOrThrow("default"), NodeType.tenant);
nodeRepository.addNodes(Collections.singletonList(node));
Node hostNode = nodeRepository.createNode("openStackId2", "parent", Optional.empty(), nodeFlavors.getFlavorOrThrow("default"), NodeType.proxy);
nodeRepository.addNodes(Collections.singletonList(hostNode));
Map<String, Number> expectedMetrics = new HashMap<>();
expectedMetrics.put("hostedVespa.provisionedHosts", 1L);
expectedMetrics.put("hostedVespa.parkedHosts", 0L);
expectedMetrics.put("hostedVespa.readyHosts", 0L);
expectedMetrics.put("hostedVespa.reservedHosts", 0L);
expectedMetrics.put("hostedVespa.activeHosts", 0L);
expectedMetrics.put("hostedVespa.inactiveHosts", 0L);
expectedMetrics.put("hostedVespa.dirtyHosts", 0L);
expectedMetrics.put("hostedVespa.failedHosts", 0L);
expectedMetrics.put("hostedVespa.docker.totalCapacityDisk", 0.0);
expectedMetrics.put("hostedVespa.docker.totalCapacityMem", 0.0);
expectedMetrics.put("hostedVespa.docker.totalCapacityCpu", 0.0);
expectedMetrics.put("hostedVespa.docker.freeCapacityDisk", 0.0);
expectedMetrics.put("hostedVespa.docker.freeCapacityMem", 0.0);
expectedMetrics.put("hostedVespa.docker.freeCapacityCpu", 0.0);
expectedMetrics.put("wantedRebootGeneration", 0L);
expectedMetrics.put("currentRebootGeneration", 0L);
expectedMetrics.put("wantToReboot", 0);
expectedMetrics.put("wantToRetire", 0);
expectedMetrics.put("wantToDeprovision", 0);
expectedMetrics.put("hardwareFailure", 0);
expectedMetrics.put("hardwareDivergence", 0);
expectedMetrics.put("allowedToBeDown", 0);
expectedMetrics.put("numberOfServices", 0L);
Orchestrator orchestrator = mock(Orchestrator.class);
ServiceMonitor serviceMonitor = mock(ServiceMonitor.class);
when(orchestrator.getNodeStatus(any())).thenReturn(HostStatus.NO_REMARKS);
ServiceModel serviceModel = mock(ServiceModel.class);
when(serviceMonitor.getServiceModelSnapshot()).thenReturn(serviceModel);
when(serviceModel.getServiceInstancesByHostName()).thenReturn(Collections.emptyMap());
TestMetric metric = new TestMetric();
MetricsReporter metricsReporter = new MetricsReporter(nodeRepository, metric, orchestrator, serviceMonitor, Duration.ofMinutes(1), new JobControl(nodeRepository.database()));
metricsReporter.maintain();
assertEquals(expectedMetrics, metric.values);
}
Aggregations