Search in sources :

Example 1 with NodeList

use of com.yahoo.vespa.hosted.provision.NodeList in project vespa by vespa-engine.

the class AllocationSimulator method addCluster.

/* ------------ Methods to add events to the system ----------------*/
public void addCluster(String task, int count, Flavor flavor, String id) {
    // TODO: Implement
    NodeSpec.CountNodeSpec nodeSpec = new NodeSpec.CountNodeSpec(count, flavor, false);
    nodes = new NodeList(nodes.asList());
}
Also used : NodeList(com.yahoo.vespa.hosted.provision.NodeList)

Example 2 with NodeList

use of com.yahoo.vespa.hosted.provision.NodeList in project vespa by vespa-engine.

the class NodePrioritizer method addNewDockerNodes.

/**
 * Add a node on each docker host with enough capacity for the requested flavor
 */
void addNewDockerNodes() {
    if (!isDocker)
        return;
    DockerHostCapacity capacity = new DockerHostCapacity(allNodes);
    ResourceCapacity wantedResourceCapacity = ResourceCapacity.of(getFlavor(requestedNodes));
    NodeList list = new NodeList(allNodes);
    for (Node node : allNodes) {
        if (node.type() != NodeType.host)
            continue;
        if (node.state() != Node.State.active)
            continue;
        if (node.status().wantToRetire())
            continue;
        boolean hostHasCapacityForWantedFlavor = capacity.hasCapacity(node, wantedResourceCapacity);
        boolean conflictingCluster = list.childrenOf(node).owner(appId).asList().stream().anyMatch(child -> child.allocation().get().membership().cluster().id().equals(clusterSpec.id()));
        if (!hostHasCapacityForWantedFlavor || conflictingCluster)
            continue;
        log.log(LogLevel.DEBUG, "Trying to add new Docker node on " + node);
        Set<String> ipAddresses = DockerHostCapacity.findFreeIps(node, allNodes);
        if (ipAddresses.isEmpty())
            continue;
        String ipAddress = ipAddresses.stream().findFirst().get();
        Optional<String> hostname = nameResolver.getHostname(ipAddress);
        if (!hostname.isPresent()) {
            log.log(LogLevel.DEBUG, "Could not find hostname for " + ipAddress + ", skipping it");
            continue;
        }
        Node newNode = Node.createDockerNode("fake-" + hostname.get(), Collections.singleton(ipAddress), Collections.emptySet(), hostname.get(), Optional.of(node.hostname()), getFlavor(requestedNodes), NodeType.tenant);
        PrioritizableNode nodePri = toNodePriority(newNode, false, true);
        if (!nodePri.violatesSpares || isAllocatingForReplacement) {
            log.log(LogLevel.DEBUG, "Adding new Docker node " + newNode);
            nodes.put(newNode, nodePri);
        }
    }
}
Also used : NodeList(com.yahoo.vespa.hosted.provision.NodeList) Node(com.yahoo.vespa.hosted.provision.Node)

Example 3 with NodeList

use of com.yahoo.vespa.hosted.provision.NodeList in project vespa by vespa-engine.

the class DynamicDockerProvisioningTest method findSpareCapacity.

private List<Node> findSpareCapacity(ProvisioningTester tester) {
    List<Node> nodes = tester.nodeRepository().getNodes(Node.State.values());
    NodeList nl = new NodeList(nodes);
    return nodes.stream().filter(n -> n.type() == NodeType.host).filter(// Nodes without children
    n -> nl.childrenOf(n).size() == 0).collect(Collectors.toList());
}
Also used : CoreMatchers.is(org.hamcrest.CoreMatchers.is) Capacity(com.yahoo.config.provision.Capacity) Version(com.yahoo.component.Version) ApplicationId(com.yahoo.config.provision.ApplicationId) ClusterMembership(com.yahoo.config.provision.ClusterMembership) ClusterSpec(com.yahoo.config.provision.ClusterSpec) HashMap(java.util.HashMap) Node(com.yahoo.vespa.hosted.provision.Node) RegionName(com.yahoo.config.provision.RegionName) HashSet(java.util.HashSet) Assert.assertThat(org.junit.Assert.assertThat) CuratorTransaction(com.yahoo.vespa.curator.transaction.CuratorTransaction) NestedTransaction(com.yahoo.transaction.NestedTransaction) Map(java.util.Map) NodeList(com.yahoo.vespa.hosted.provision.NodeList) Assert.fail(org.junit.Assert.fail) ImmutableSet(com.google.common.collect.ImmutableSet) Environment(com.yahoo.config.provision.Environment) NodeType(com.yahoo.config.provision.NodeType) OutOfCapacityException(com.yahoo.config.provision.OutOfCapacityException) HostSpec(com.yahoo.config.provision.HostSpec) FlavorsConfig(com.yahoo.config.provisioning.FlavorsConfig) Set(java.util.Set) Test(org.junit.Test) Instant(java.time.Instant) Collectors(java.util.stream.Collectors) List(java.util.List) Agent(com.yahoo.vespa.hosted.provision.node.Agent) Flavor(com.yahoo.config.provision.Flavor) Zone(com.yahoo.config.provision.Zone) Optional(java.util.Optional) Matchers.greaterThan(org.hamcrest.Matchers.greaterThan) Assert(org.junit.Assert) Collections(java.util.Collections) Assert.assertEquals(org.junit.Assert.assertEquals) Node(com.yahoo.vespa.hosted.provision.Node) NodeList(com.yahoo.vespa.hosted.provision.NodeList)

Example 4 with NodeList

use of com.yahoo.vespa.hosted.provision.NodeList in project vespa by vespa-engine.

the class ProvisioningTest method application_deployment_retires_nodes_having_retired_flavor.

@Test
public void application_deployment_retires_nodes_having_retired_flavor() {
    String flavorToRetire = "default";
    String replacementFlavor = "new-default";
    ApplicationId application = ApplicationId.from(TenantName.from(UUID.randomUUID().toString()), ApplicationName.from(UUID.randomUUID().toString()), InstanceName.from(UUID.randomUUID().toString()));
    Curator curator = new MockCurator();
    NameResolver nameResolver = new MockNameResolver().mockAnyLookup();
    // Deploy with flavor that will eventually be retired
    {
        FlavorConfigBuilder b = new FlavorConfigBuilder();
        b.addFlavor("default", 1., 1., 10, Flavor.Type.BARE_METAL).cost(2);
        ProvisioningTester tester = new ProvisioningTester(new Zone(Environment.prod, RegionName.from("us-east")), b.build(), curator, nameResolver);
        tester.makeReadyNodes(4, flavorToRetire);
        SystemState state = prepare(application, 2, 0, 2, 0, flavorToRetire, tester);
        tester.activate(application, state.allHosts);
    }
    // Re-deploy with same flavor, which is now retired
    {
        // Retire "default" flavor and add "new-default" as replacement
        FlavorConfigBuilder b = new FlavorConfigBuilder();
        b.addFlavor(flavorToRetire, 1., 1., 10, Flavor.Type.BARE_METAL).cost(2).retired(true);
        FlavorsConfig.Flavor.Builder newDefault = b.addFlavor(replacementFlavor, 2., 2., 20, Flavor.Type.BARE_METAL).cost(2);
        b.addReplaces(flavorToRetire, newDefault);
        ProvisioningTester tester = new ProvisioningTester(new Zone(Environment.prod, RegionName.from("us-east")), b.build(), curator, nameResolver);
        // Add nodes with "new-default" flavor
        tester.makeReadyNodes(4, replacementFlavor);
        SystemState state = prepare(application, 2, 0, 2, 0, flavorToRetire, tester);
        tester.activate(application, state.allHosts);
        // Nodes with retired flavor are retired
        NodeList retired = tester.getNodes(application).retired();
        assertEquals(4, retired.size());
        assertTrue("Nodes are retired by system", retired.asList().stream().allMatch(retiredBy(Agent.system)));
    }
}
Also used : MockNameResolver(com.yahoo.vespa.hosted.provision.testutils.MockNameResolver) Zone(com.yahoo.config.provision.Zone) NodeList(com.yahoo.vespa.hosted.provision.NodeList) Curator(com.yahoo.vespa.curator.Curator) MockCurator(com.yahoo.vespa.curator.mock.MockCurator) ApplicationId(com.yahoo.config.provision.ApplicationId) FlavorsConfig(com.yahoo.config.provisioning.FlavorsConfig) NameResolver(com.yahoo.vespa.hosted.provision.persistence.NameResolver) MockNameResolver(com.yahoo.vespa.hosted.provision.testutils.MockNameResolver) MockCurator(com.yahoo.vespa.curator.mock.MockCurator) Test(org.junit.Test)

Example 5 with NodeList

use of com.yahoo.vespa.hosted.provision.NodeList in project vespa by vespa-engine.

the class DockerProvisioningTest method get_specified_flavor_not_default_flavor_for_docker.

// In dev, test and staging you get nodes with default flavor, but we should get specified flavor for docker nodes
@Test
public void get_specified_flavor_not_default_flavor_for_docker() {
    ProvisioningTester tester = new ProvisioningTester(new Zone(Environment.test, RegionName.from("corp-us-east-1")));
    ApplicationId application1 = tester.makeApplicationId();
    tester.makeReadyDockerNodes(1, dockerFlavor, "dockerHost");
    List<HostSpec> hosts = tester.prepare(application1, ClusterSpec.request(ClusterSpec.Type.content, ClusterSpec.Id.from("myContent"), Version.fromString("6.42"), false), 1, 1, dockerFlavor);
    tester.activate(application1, new HashSet<>(hosts));
    NodeList nodes = tester.getNodes(application1, Node.State.active);
    assertEquals(1, nodes.size());
    assertEquals(dockerFlavor, nodes.asList().get(0).flavor().canonicalName());
}
Also used : Zone(com.yahoo.config.provision.Zone) NodeList(com.yahoo.vespa.hosted.provision.NodeList) ApplicationId(com.yahoo.config.provision.ApplicationId) HostSpec(com.yahoo.config.provision.HostSpec) Test(org.junit.Test)

Aggregations

NodeList (com.yahoo.vespa.hosted.provision.NodeList)7 ApplicationId (com.yahoo.config.provision.ApplicationId)4 Zone (com.yahoo.config.provision.Zone)4 Test (org.junit.Test)4 HostSpec (com.yahoo.config.provision.HostSpec)3 Node (com.yahoo.vespa.hosted.provision.Node)3 Version (com.yahoo.component.Version)2 FlavorsConfig (com.yahoo.config.provisioning.FlavorsConfig)2 ImmutableSet (com.google.common.collect.ImmutableSet)1 Capacity (com.yahoo.config.provision.Capacity)1 ClusterMembership (com.yahoo.config.provision.ClusterMembership)1 ClusterSpec (com.yahoo.config.provision.ClusterSpec)1 Environment (com.yahoo.config.provision.Environment)1 Flavor (com.yahoo.config.provision.Flavor)1 NodeType (com.yahoo.config.provision.NodeType)1 OutOfCapacityException (com.yahoo.config.provision.OutOfCapacityException)1 RegionName (com.yahoo.config.provision.RegionName)1 NestedTransaction (com.yahoo.transaction.NestedTransaction)1 Curator (com.yahoo.vespa.curator.Curator)1 MockCurator (com.yahoo.vespa.curator.mock.MockCurator)1