Search in sources :

Example 6 with ClusterSpec

use of com.yahoo.config.provision.ClusterSpec in project vespa by vespa-engine.

the class NodeFailTester method withTwoApplications.

public static NodeFailTester withTwoApplications(ConfigserverConfig configserverConfig) {
    NodeFailTester tester = new NodeFailTester(configserverConfig);
    tester.createReadyNodes(16);
    tester.createHostNodes(3);
    // Create applications
    ClusterSpec clusterApp1 = ClusterSpec.request(ClusterSpec.Type.container, ClusterSpec.Id.from("test"), Version.fromString("6.42"), false);
    ClusterSpec clusterApp2 = ClusterSpec.request(ClusterSpec.Type.content, ClusterSpec.Id.from("test"), Version.fromString("6.42"), false);
    int wantedNodesApp1 = 5;
    int wantedNodesApp2 = 7;
    tester.activate(app1, clusterApp1, wantedNodesApp1);
    tester.activate(app2, clusterApp2, wantedNodesApp2);
    assertEquals(wantedNodesApp1, tester.nodeRepository.getNodes(app1, Node.State.active).size());
    assertEquals(wantedNodesApp2, tester.nodeRepository.getNodes(app2, Node.State.active).size());
    Map<ApplicationId, MockDeployer.ApplicationContext> apps = new HashMap<>();
    apps.put(app1, new MockDeployer.ApplicationContext(app1, clusterApp1, Capacity.fromNodeCount(wantedNodesApp1, Optional.of("default"), false), 1));
    apps.put(app2, new MockDeployer.ApplicationContext(app2, clusterApp2, Capacity.fromNodeCount(wantedNodesApp2, Optional.of("default"), false), 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) ClusterSpec(com.yahoo.config.provision.ClusterSpec) ApplicationId(com.yahoo.config.provision.ApplicationId) MetricsReporterTest(com.yahoo.vespa.hosted.provision.monitoring.MetricsReporterTest) MockDeployer(com.yahoo.vespa.hosted.provision.testutils.MockDeployer)

Example 7 with ClusterSpec

use of com.yahoo.config.provision.ClusterSpec 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 8 with ClusterSpec

use of com.yahoo.config.provision.ClusterSpec 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 9 with ClusterSpec

use of com.yahoo.config.provision.ClusterSpec 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 10 with ClusterSpec

use of com.yahoo.config.provision.ClusterSpec in project vespa by vespa-engine.

the class NodeTypeProvisioningTest method retire_proxy.

@Test
public void retire_proxy() {
    MockDeployer deployer = new MockDeployer(tester.provisioner(), Collections.singletonMap(application, new MockDeployer.ApplicationContext(application, clusterSpec, capacity, 1)));
    RetiredExpirer retiredExpirer = new RetiredExpirer(tester.nodeRepository(), tester.orchestrator(), deployer, tester.clock(), Duration.ofDays(30), Duration.ofMinutes(10), new JobControl(tester.nodeRepository().database()));
    {
        // Deploy
        List<HostSpec> hosts = deployProxies(application, tester);
        assertEquals("Reserved all proxies", 11, hosts.size());
        tester.activate(application, new HashSet<>(hosts));
        List<Node> nodes = tester.nodeRepository().getNodes(NodeType.proxy, Node.State.active);
        assertEquals("Activated all proxies", 11, nodes.size());
    }
    Node nodeToRetire = tester.nodeRepository().getNodes(NodeType.proxy, Node.State.active).get(5);
    {
        // Pick out a node and retire it
        tester.nodeRepository().write(nodeToRetire.with(nodeToRetire.status().withWantToRetire(true)));
        List<HostSpec> hosts = deployProxies(application, tester);
        assertEquals(11, hosts.size());
        tester.activate(application, new HashSet<>(hosts));
        List<Node> nodes = tester.nodeRepository().getNodes(NodeType.proxy, Node.State.active);
        assertEquals(11, nodes.size());
        // Verify that wantToRetire has been propagated
        assertTrue(tester.nodeRepository().getNode(nodeToRetire.hostname()).flatMap(Node::allocation).map(allocation -> allocation.membership().retired()).orElseThrow(RuntimeException::new));
    }
    {
        // Redeploying while the node is still retiring has no effect
        List<HostSpec> hosts = deployProxies(application, tester);
        assertEquals(11, hosts.size());
        tester.activate(application, new HashSet<>(hosts));
        List<Node> nodes = tester.nodeRepository().getNodes(NodeType.proxy, Node.State.active);
        assertEquals(11, nodes.size());
        // Verify that the node is still marked as retired
        assertTrue(tester.nodeRepository().getNode(nodeToRetire.hostname()).flatMap(Node::allocation).map(allocation -> allocation.membership().retired()).orElseThrow(RuntimeException::new));
    }
    {
        tester.advanceTime(Duration.ofMinutes(11));
        retiredExpirer.run();
        List<HostSpec> hosts = deployProxies(application, tester);
        assertEquals(10, hosts.size());
        tester.activate(application, new HashSet<>(hosts));
        List<Node> nodes = tester.nodeRepository().getNodes(NodeType.proxy, Node.State.active);
        assertEquals(10, nodes.size());
        // Verify that the node is now inactive
        assertEquals(Node.State.inactive, tester.nodeRepository().getNode(nodeToRetire.hostname()).orElseThrow(RuntimeException::new).state());
    }
}
Also used : Capacity(com.yahoo.config.provision.Capacity) Version(com.yahoo.component.Version) ApplicationId(com.yahoo.config.provision.ApplicationId) Environment(com.yahoo.config.provision.Environment) NodeType(com.yahoo.config.provision.NodeType) JobControl(com.yahoo.vespa.hosted.provision.maintenance.JobControl) ClusterSpec(com.yahoo.config.provision.ClusterSpec) HostSpec(com.yahoo.config.provision.HostSpec) Assert.assertTrue(org.junit.Assert.assertTrue) Test(org.junit.Test) Node(com.yahoo.vespa.hosted.provision.Node) Collectors(java.util.stream.Collectors) RegionName(com.yahoo.config.provision.RegionName) Assert.assertNotEquals(org.junit.Assert.assertNotEquals) MockDeployer(com.yahoo.vespa.hosted.provision.testutils.MockDeployer) HashSet(java.util.HashSet) RetiredExpirer(com.yahoo.vespa.hosted.provision.maintenance.RetiredExpirer) List(java.util.List) Agent(com.yahoo.vespa.hosted.provision.node.Agent) Duration(java.time.Duration) Zone(com.yahoo.config.provision.Zone) Collections(java.util.Collections) Assert.assertEquals(org.junit.Assert.assertEquals) Before(org.junit.Before) Node(com.yahoo.vespa.hosted.provision.Node) JobControl(com.yahoo.vespa.hosted.provision.maintenance.JobControl) List(java.util.List) RetiredExpirer(com.yahoo.vespa.hosted.provision.maintenance.RetiredExpirer) MockDeployer(com.yahoo.vespa.hosted.provision.testutils.MockDeployer) HashSet(java.util.HashSet) Test(org.junit.Test)

Aggregations

ClusterSpec (com.yahoo.config.provision.ClusterSpec)32 Node (com.yahoo.vespa.hosted.provision.Node)23 ApplicationId (com.yahoo.config.provision.ApplicationId)20 Test (org.junit.Test)18 Zone (com.yahoo.config.provision.Zone)14 MockDeployer (com.yahoo.vespa.hosted.provision.testutils.MockDeployer)10 HashSet (java.util.HashSet)10 Flavor (com.yahoo.config.provision.Flavor)9 HostSpec (com.yahoo.config.provision.HostSpec)9 Capacity (com.yahoo.config.provision.Capacity)7 ArrayList (java.util.ArrayList)6 Version (com.yahoo.component.Version)5 ClusterMembership (com.yahoo.config.provision.ClusterMembership)5 List (java.util.List)5 Collections (java.util.Collections)4 HashMap (java.util.HashMap)4 Assert.assertTrue (org.junit.Assert.assertTrue)4 Environment (com.yahoo.config.provision.Environment)3 NodeType (com.yahoo.config.provision.NodeType)3 RegionName (com.yahoo.config.provision.RegionName)3