Search in sources :

Example 1 with NodeFlavors

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

the class ProvisioningTest method application_deployment_multiple_flavors_default_per_type.

@Test
public void application_deployment_multiple_flavors_default_per_type() {
    ConfigserverConfig.Builder config = new ConfigserverConfig.Builder();
    config.environment("prod");
    config.region("us-east");
    config.defaultFlavor("not-used");
    config.defaultContainerFlavor("small");
    config.defaultContentFlavor("large");
    ProvisioningTester tester = new ProvisioningTester(new Zone(new ConfigserverConfig(config), new NodeFlavors(new FlavorsConfig(new FlavorsConfig.Builder()))));
    ApplicationId application1 = tester.makeApplicationId();
    tester.makeReadyNodes(10, "small");
    tester.makeReadyNodes(9, "large");
    // deploy
    SystemState state1 = prepare(application1, 2, 3, 4, 5, null, tester);
    tester.activate(application1, state1.allHosts);
    assertEquals("'small' nodes are used for containers", 2 + 3, tester.getNodes(application1, Node.State.active).flavor("small").size());
    assertEquals("'large' nodes are used for content", 4 + 5, tester.getNodes(application1, Node.State.active).flavor("large").size());
}
Also used : ConfigserverConfig(com.yahoo.cloud.config.ConfigserverConfig) NodeFlavors(com.yahoo.config.provision.NodeFlavors) Zone(com.yahoo.config.provision.Zone) ApplicationId(com.yahoo.config.provision.ApplicationId) FlavorsConfig(com.yahoo.config.provisioning.FlavorsConfig) Test(org.junit.Test)

Example 2 with NodeFlavors

use of com.yahoo.config.provision.NodeFlavors 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)

Example 3 with NodeFlavors

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

the class DockerHostCapacityTest method setup.

@Before
public void setup() {
    // Create flavors
    NodeFlavors nodeFlavors = FlavorConfigBuilder.createDummies("host", "docker", "docker2");
    flavorDocker = nodeFlavors.getFlavorOrThrow("docker");
    flavorDocker2 = nodeFlavors.getFlavorOrThrow("docker2");
    // Create three docker hosts
    host1 = Node.create("host1", Collections.singleton("::1"), generateIPs(2, 4), "host1", Optional.empty(), nodeFlavors.getFlavorOrThrow("host"), NodeType.host);
    host2 = Node.create("host2", Collections.singleton("::11"), generateIPs(12, 3), "host2", Optional.empty(), nodeFlavors.getFlavorOrThrow("host"), NodeType.host);
    host3 = Node.create("host3", Collections.singleton("::21"), generateIPs(22, 1), "host3", Optional.empty(), nodeFlavors.getFlavorOrThrow("host"), NodeType.host);
    // Add two containers to host1
    nodeA = Node.create("nodeA", Collections.singleton("::2"), Collections.emptySet(), "nodeA", Optional.of("host1"), flavorDocker, NodeType.tenant);
    nodeB = Node.create("nodeB", Collections.singleton("::3"), Collections.emptySet(), "nodeB", Optional.of("host1"), flavorDocker, NodeType.tenant);
    // Add two containers to host 2 (same as host 1)
    nodeC = Node.create("nodeC", Collections.singleton("::12"), Collections.emptySet(), "nodeC", Optional.of("host2"), flavorDocker, NodeType.tenant);
    nodeD = Node.create("nodeD", Collections.singleton("::13"), Collections.emptySet(), "nodeD", Optional.of("host2"), flavorDocker, NodeType.tenant);
    // Add a larger container to host3
    nodeE = Node.create("nodeE", Collections.singleton("::22"), Collections.emptySet(), "nodeE", Optional.of("host3"), flavorDocker2, NodeType.tenant);
    // init docker host capacity
    nodes = new ArrayList<>();
    Collections.addAll(nodes, host1, host2, host3, nodeA, nodeB, nodeC, nodeD, nodeE);
    capacity = new DockerHostCapacity(nodes);
}
Also used : NodeFlavors(com.yahoo.config.provision.NodeFlavors) Before(org.junit.Before)

Example 4 with NodeFlavors

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

the class AuthorizerTest method before.

@Before
public void before() {
    NodeFlavors flavors = new MockNodeFlavors();
    nodeRepository = new MockNodeRepository(new MockCurator(), flavors);
    authorizer = new Authorizer(SystemName.main, nodeRepository, () -> "cfg1");
    {
        // Populate with nodes used in this test. Note that only nodes requiring node repository lookup are added here
        Set<String> ipAddresses = new HashSet<>(Arrays.asList("127.0.0.1", "::1"));
        Flavor flavor = flavors.getFlavorOrThrow("default");
        List<Node> nodes = new ArrayList<>();
        nodes.add(nodeRepository.createNode("host1", "host1", ipAddresses, Optional.empty(), flavor, NodeType.host));
        nodes.add(nodeRepository.createNode("child1-1", "child1-1", ipAddresses, Optional.of("host1"), flavor, NodeType.tenant));
        nodes.add(nodeRepository.createNode("child1-2", "child1-2", ipAddresses, Optional.of("host1"), flavor, NodeType.tenant));
        nodes.add(nodeRepository.createNode("host2", "host2", ipAddresses, Optional.empty(), flavor, NodeType.host));
        nodes.add(nodeRepository.createNode("child2-1", "child2-1", ipAddresses, Optional.of("host1.tld"), flavor, NodeType.tenant));
        nodes.add(nodeRepository.createNode("proxy1", "proxy1", ipAddresses, Optional.empty(), flavor, NodeType.proxy));
        nodes.add(nodeRepository.createNode("proxy1-host1", "proxy1-host", ipAddresses, Optional.empty(), flavor, NodeType.proxyhost));
        nodeRepository.addNodes(nodes);
    }
}
Also used : MockNodeFlavors(com.yahoo.vespa.hosted.provision.testutils.MockNodeFlavors) Set(java.util.Set) HashSet(java.util.HashSet) NodeFlavors(com.yahoo.config.provision.NodeFlavors) MockNodeFlavors(com.yahoo.vespa.hosted.provision.testutils.MockNodeFlavors) MockNodeRepository(com.yahoo.vespa.hosted.provision.testutils.MockNodeRepository) ArrayList(java.util.ArrayList) List(java.util.List) Flavor(com.yahoo.config.provision.Flavor) MockCurator(com.yahoo.vespa.curator.mock.MockCurator) Before(org.junit.Before)

Example 5 with NodeFlavors

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

the class ReservationExpirerTest method ensure_reservation_times_out.

@Test
public void ensure_reservation_times_out() {
    ManualClock clock = new ManualClock();
    NodeFlavors flavors = FlavorConfigBuilder.createDummies("default");
    NodeRepository nodeRepository = new NodeRepository(flavors, curator, clock, Zone.defaultZone(), new MockNameResolver().mockAnyLookup(), new DockerImage("docker-registry.domain.tld:8080/dist/vespa"), true);
    NodeRepositoryProvisioner provisioner = new NodeRepositoryProvisioner(nodeRepository, flavors, Zone.defaultZone());
    List<Node> nodes = new ArrayList<>(2);
    nodes.add(nodeRepository.createNode(UUID.randomUUID().toString(), UUID.randomUUID().toString(), Optional.empty(), flavors.getFlavorOrThrow("default"), NodeType.tenant));
    nodes.add(nodeRepository.createNode(UUID.randomUUID().toString(), UUID.randomUUID().toString(), Optional.empty(), flavors.getFlavorOrThrow("default"), NodeType.tenant));
    nodes.add(nodeRepository.createNode(UUID.randomUUID().toString(), UUID.randomUUID().toString(), Optional.empty(), flavors.getFlavorOrThrow("default"), NodeType.host));
    nodes = nodeRepository.addNodes(nodes);
    nodes = nodeRepository.setDirty(nodes, Agent.system, getClass().getSimpleName());
    // Reserve 2 nodes
    assertEquals(2, nodeRepository.getNodes(NodeType.tenant, Node.State.dirty).size());
    nodeRepository.setReady(nodes, Agent.system, getClass().getSimpleName());
    ApplicationId applicationId = new ApplicationId.Builder().tenant("foo").applicationName("bar").instanceName("fuz").build();
    ClusterSpec cluster = ClusterSpec.request(ClusterSpec.Type.content, ClusterSpec.Id.from("test"), Version.fromString("6.42"), false);
    provisioner.prepare(applicationId, cluster, Capacity.fromNodeCount(2), 1, null);
    assertEquals(2, nodeRepository.getNodes(NodeType.tenant, Node.State.reserved).size());
    // Reservation times out
    // Reserved but not used time out
    clock.advance(Duration.ofMinutes(14));
    new ReservationExpirer(nodeRepository, clock, Duration.ofMinutes(10), new JobControl(nodeRepository.database())).run();
    // Assert nothing is reserved
    assertEquals(0, nodeRepository.getNodes(NodeType.tenant, Node.State.reserved).size());
    List<Node> dirty = nodeRepository.getNodes(NodeType.tenant, Node.State.dirty);
    assertEquals(2, dirty.size());
    assertFalse(dirty.get(0).allocation().isPresent());
    assertFalse(dirty.get(1).allocation().isPresent());
}
Also used : MockNameResolver(com.yahoo.vespa.hosted.provision.testutils.MockNameResolver) Node(com.yahoo.vespa.hosted.provision.Node) FlavorConfigBuilder(com.yahoo.vespa.hosted.provision.provisioning.FlavorConfigBuilder) NodeRepositoryProvisioner(com.yahoo.vespa.hosted.provision.provisioning.NodeRepositoryProvisioner) ArrayList(java.util.ArrayList) ClusterSpec(com.yahoo.config.provision.ClusterSpec) ManualClock(com.yahoo.test.ManualClock) NodeFlavors(com.yahoo.config.provision.NodeFlavors) NodeRepository(com.yahoo.vespa.hosted.provision.NodeRepository) DockerImage(com.yahoo.config.provision.DockerImage) ApplicationId(com.yahoo.config.provision.ApplicationId) Test(org.junit.Test)

Aggregations

NodeFlavors (com.yahoo.config.provision.NodeFlavors)8 Node (com.yahoo.vespa.hosted.provision.Node)5 Test (org.junit.Test)4 ApplicationId (com.yahoo.config.provision.ApplicationId)3 DockerImage (com.yahoo.config.provision.DockerImage)3 MockCurator (com.yahoo.vespa.curator.mock.MockCurator)3 NodeRepository (com.yahoo.vespa.hosted.provision.NodeRepository)3 MockNameResolver (com.yahoo.vespa.hosted.provision.testutils.MockNameResolver)3 ArrayList (java.util.ArrayList)3 HashSet (java.util.HashSet)3 Before (org.junit.Before)3 ClusterSpec (com.yahoo.config.provision.ClusterSpec)2 Flavor (com.yahoo.config.provision.Flavor)2 Curator (com.yahoo.vespa.curator.Curator)2 JobControl (com.yahoo.vespa.hosted.provision.maintenance.JobControl)2 MetricsReporter (com.yahoo.vespa.hosted.provision.maintenance.MetricsReporter)2 Orchestrator (com.yahoo.vespa.orchestrator.Orchestrator)2 ServiceModel (com.yahoo.vespa.service.monitor.ServiceModel)2 ServiceMonitor (com.yahoo.vespa.service.monitor.ServiceMonitor)2 HashMap (java.util.HashMap)2