Search in sources :

Example 56 with Node

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

the class IdentityDocumentGenerator method generateSignedIdentityDocument.

public SignedIdentityDocument generateSignedIdentityDocument(String hostname) {
    Node node = nodeRepository.getNode(hostname).orElseThrow(() -> new RuntimeException("Unable to find node " + hostname));
    try {
        IdentityDocument identityDocument = generateIdDocument(node);
        String identityDocumentString = Utils.getMapper().writeValueAsString(identityDocument);
        String encodedIdentityDocument = Base64.getEncoder().encodeToString(identityDocumentString.getBytes());
        Signature sigGenerator = Signature.getInstance("SHA512withRSA");
        PrivateKey privateKey = keyProvider.getPrivateKey(zoneConfig.secretVersion());
        sigGenerator.initSign(privateKey);
        sigGenerator.update(encodedIdentityDocument.getBytes());
        String signature = Base64.getEncoder().encodeToString(sigGenerator.sign());
        return new SignedIdentityDocument(encodedIdentityDocument, signature, SignedIdentityDocument.DEFAULT_KEY_VERSION, identityDocument.providerUniqueId.asString(), toZoneDnsSuffix(zone, zoneConfig.certDnsSuffix()), zoneConfig.domain() + "." + zoneConfig.serviceName(), zoneConfig.ztsUrl(), SignedIdentityDocument.DEFAULT_DOCUMENT_VERSION);
    } catch (Exception e) {
        throw new RuntimeException("Exception generating identity document: " + e.getMessage(), e);
    }
}
Also used : PrivateKey(java.security.PrivateKey) Node(com.yahoo.vespa.hosted.provision.Node) Signature(java.security.Signature)

Example 57 with Node

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

the class AclProvisioningTest method trusted_nodes_for_unallocated_node.

@Test
public void trusted_nodes_for_unallocated_node() {
    List<Node> configServers = setConfigServers("cfg1:1234,cfg2:1234,cfg3:1234");
    // Populate repo
    tester.makeReadyNodes(10, "default");
    List<Node> proxyNodes = tester.makeReadyNodes(3, "default", NodeType.proxy);
    // Allocate 2 nodes to an application
    allocateNodes(2);
    // Get trusted nodes for a ready tenant node
    Node node = tester.nodeRepository().getNodes(NodeType.tenant, Node.State.ready).get(0);
    List<NodeAcl> nodeAcls = tester.nodeRepository().getNodeAcls(node, false);
    List<Node> tenantNodes = tester.nodeRepository().getNodes(NodeType.tenant);
    // Trusted nodes are all proxy-, config-, and, tenant-nodes
    assertAcls(Arrays.asList(proxyNodes, configServers, tenantNodes), nodeAcls);
}
Also used : Node(com.yahoo.vespa.hosted.provision.Node) NodeAcl(com.yahoo.vespa.hosted.provision.node.NodeAcl) Test(org.junit.Test)

Example 58 with Node

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

the class AclProvisioningTest method trusted_nodes_for_docker_host.

@Test
public void trusted_nodes_for_docker_host() {
    List<Node> configServers = setConfigServers("cfg1:1234,cfg2:1234,cfg3:1234");
    // Populate repo
    tester.makeReadyNodes(2, "default", NodeType.host);
    // Deploy zone application
    ApplicationId zoneApplication = tester.makeApplicationId();
    allocateNodes(Capacity.fromRequiredNodeType(NodeType.host), zoneApplication);
    List<Node> dockerHostNodes = tester.nodeRepository().getNodes(zoneApplication);
    List<NodeAcl> acls = tester.nodeRepository().getNodeAcls(dockerHostNodes.get(0), false);
    // Trusted nodes is all Docker hosts and all config servers
    assertAcls(Arrays.asList(dockerHostNodes, configServers), dockerBridgeNetwork, acls.get(0));
}
Also used : Node(com.yahoo.vespa.hosted.provision.Node) NodeAcl(com.yahoo.vespa.hosted.provision.node.NodeAcl) ApplicationId(com.yahoo.config.provision.ApplicationId) Test(org.junit.Test)

Example 59 with Node

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

the class DynamicDockerProvisioningTest method do_not_relocate_nodes_from_spare_if_no_where_to_reloacte_them.

/**
 * Test redeployment of nodes that violates spare headroom - but without alternatives
 * <p>
 * Setup 2 docker hosts and allocate one app with a container on each
 * No headroom defined - only 2 spares.
 * <p>
 * Initial allocation of app 1 --> final allocation:
 * <p>
 * |    |    |        |    |    |
 * |    |    |   -->  |    |    |
 * | 1a | 1b |        | 1a | 1b |
 */
@Test
public void do_not_relocate_nodes_from_spare_if_no_where_to_reloacte_them() {
    ProvisioningTester tester = new ProvisioningTester(new Zone(Environment.prod, RegionName.from("us-east")), flavorsConfig());
    tester.makeReadyNodes(2, "host-small", NodeType.host, 32);
    deployZoneApp(tester);
    List<Node> dockerHosts = tester.nodeRepository().getNodes(NodeType.host, Node.State.active);
    Flavor flavor = tester.nodeRepository().getAvailableFlavors().getFlavorOrThrow("d-1");
    // Application 1
    ApplicationId application1 = makeApplicationId("t1", "a1");
    ClusterSpec clusterSpec1 = ClusterSpec.request(ClusterSpec.Type.content, ClusterSpec.Id.from("myContent"), Version.fromString("6.100"), false);
    addAndAssignNode(application1, "1a", dockerHosts.get(0).hostname(), flavor, 0, tester);
    addAndAssignNode(application1, "1b", dockerHosts.get(1).hostname(), flavor, 1, tester);
    // Redeploy both applications (to be agnostic on which hosts are picked as spares)
    deployapp(application1, clusterSpec1, flavor, tester, 2);
    // Assert that we have two spare nodes (two hosts that are don't have allocations)
    Set<String> hostsWithChildren = new HashSet<>();
    for (Node node : tester.nodeRepository().getNodes(NodeType.tenant, Node.State.active)) {
        if (!isInactiveOrRetired(node)) {
            hostsWithChildren.add(node.parentHostname().get());
        }
    }
    Assert.assertEquals(2, hostsWithChildren.size());
}
Also used : Zone(com.yahoo.config.provision.Zone) Node(com.yahoo.vespa.hosted.provision.Node) ClusterSpec(com.yahoo.config.provision.ClusterSpec) ApplicationId(com.yahoo.config.provision.ApplicationId) Flavor(com.yahoo.config.provision.Flavor) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 60 with Node

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

the class DynamicDockerProvisioningTest method assertApplicationHosts.

private void assertApplicationHosts(List<Node> nodes, String... parents) {
    for (Node node : nodes) {
        // Ignore retired and non-active nodes
        if (!node.state().equals(Node.State.active) || node.allocation().get().membership().retired()) {
            continue;
        }
        boolean found = false;
        for (String parent : parents) {
            if (node.parentHostname().get().equals(parent)) {
                found = true;
                break;
            }
        }
        Assert.assertTrue(found);
    }
}
Also used : Node(com.yahoo.vespa.hosted.provision.Node)

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