Search in sources :

Example 41 with Node

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());
}
Also used : Zone(com.yahoo.config.provision.Zone) Node(com.yahoo.vespa.hosted.provision.Node) ApplicationId(com.yahoo.config.provision.ApplicationId) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 42 with Node

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;
}
Also used : ServiceMonitorStub(com.yahoo.vespa.hosted.provision.testutils.ServiceMonitorStub) HashMap(java.util.HashMap) Node(com.yahoo.vespa.hosted.provision.Node) ClusterSpec(com.yahoo.config.provision.ClusterSpec) Capacity(com.yahoo.config.provision.Capacity) ApplicationId(com.yahoo.config.provision.ApplicationId) MetricsReporterTest(com.yahoo.vespa.hosted.provision.monitoring.MetricsReporterTest) MockDeployer(com.yahoo.vespa.hosted.provision.testutils.MockDeployer)

Example 43 with Node

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());
}
Also used : OrchestrationException(com.yahoo.vespa.orchestrator.OrchestrationException) Node(com.yahoo.vespa.hosted.provision.Node) ClusterSpec(com.yahoo.config.provision.ClusterSpec) ApplicationId(com.yahoo.config.provision.ApplicationId) MockDeployer(com.yahoo.vespa.hosted.provision.testutils.MockDeployer) Test(org.junit.Test)

Example 44 with Node

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());
}
Also used : Node(com.yahoo.vespa.hosted.provision.Node) ClusterSpec(com.yahoo.config.provision.ClusterSpec) ApplicationId(com.yahoo.config.provision.ApplicationId) MockDeployer(com.yahoo.vespa.hosted.provision.testutils.MockDeployer) Test(org.junit.Test)

Example 45 with Node

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);
}
Also used : MockNameResolver(com.yahoo.vespa.hosted.provision.testutils.MockNameResolver) HashMap(java.util.HashMap) Node(com.yahoo.vespa.hosted.provision.Node) JobControl(com.yahoo.vespa.hosted.provision.maintenance.JobControl) Curator(com.yahoo.vespa.curator.Curator) MockCurator(com.yahoo.vespa.curator.mock.MockCurator) Orchestrator(com.yahoo.vespa.orchestrator.Orchestrator) ServiceMonitor(com.yahoo.vespa.service.monitor.ServiceMonitor) NodeFlavors(com.yahoo.config.provision.NodeFlavors) ServiceModel(com.yahoo.vespa.service.monitor.ServiceModel) MetricsReporter(com.yahoo.vespa.hosted.provision.maintenance.MetricsReporter) NodeRepository(com.yahoo.vespa.hosted.provision.NodeRepository) DockerImage(com.yahoo.config.provision.DockerImage) MockCurator(com.yahoo.vespa.curator.mock.MockCurator) Test(org.junit.Test)

Aggregations

Node (com.yahoo.vespa.hosted.provision.Node)121 Test (org.junit.Test)67 ApplicationId (com.yahoo.config.provision.ApplicationId)40 ClusterSpec (com.yahoo.config.provision.ClusterSpec)33 List (java.util.List)26 ArrayList (java.util.ArrayList)23 Zone (com.yahoo.config.provision.Zone)22 Flavor (com.yahoo.config.provision.Flavor)21 HashSet (java.util.HashSet)19 Collectors (java.util.stream.Collectors)19 Optional (java.util.Optional)18 NodeRepository (com.yahoo.vespa.hosted.provision.NodeRepository)16 Duration (java.time.Duration)16 HostSpec (com.yahoo.config.provision.HostSpec)15 NodeType (com.yahoo.config.provision.NodeType)15 Agent (com.yahoo.vespa.hosted.provision.node.Agent)13 Map (java.util.Map)13 HashMap (java.util.HashMap)12 Collections (java.util.Collections)11 Set (java.util.Set)11