Search in sources :

Example 26 with Node

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

the class RealNodeRepository method getContainerAclSpecs.

@Override
public List<ContainerAclSpec> getContainerAclSpecs(String hostName) {
    try {
        final String path = String.format("/nodes/v2/acl/%s?children=true", hostName);
        final GetAclResponse response = configServerApi.get(path, GetAclResponse.class);
        return response.trustedNodes.stream().map(node -> new ContainerAclSpec(node.hostname, node.ipAddress, ContainerName.fromHostname(node.trustedBy))).collect(Collectors.toList());
    } catch (HttpException.NotFoundException e) {
        return Collections.emptyList();
    }
}
Also used : NodeAttributes(com.yahoo.vespa.hosted.node.admin.nodeagent.NodeAttributes) GetAclResponse(com.yahoo.vespa.hosted.node.admin.configserver.noderepository.bindings.GetAclResponse) ContainerName(com.yahoo.vespa.hosted.dockerapi.ContainerName) Environment(com.yahoo.vespa.hosted.node.admin.component.Environment) Node(com.yahoo.vespa.hosted.provision.Node) UpdateNodeAttributesRequestBody(com.yahoo.vespa.hosted.node.admin.configserver.noderepository.bindings.UpdateNodeAttributesRequestBody) Collectors(java.util.stream.Collectors) HttpException(com.yahoo.vespa.hosted.node.admin.configserver.HttpException) ArrayList(java.util.ArrayList) Objects(java.util.Objects) List(java.util.List) ContainerNodeSpec(com.yahoo.vespa.hosted.node.admin.ContainerNodeSpec) DockerImage(com.yahoo.vespa.hosted.dockerapi.DockerImage) ConfigServerApi(com.yahoo.vespa.hosted.node.admin.configserver.ConfigServerApi) GetNodesResponse(com.yahoo.vespa.hosted.node.admin.configserver.noderepository.bindings.GetNodesResponse) ContainerAclSpec(com.yahoo.vespa.hosted.node.admin.ContainerAclSpec) Optional(java.util.Optional) SslConfigServerApiImpl(com.yahoo.vespa.hosted.node.admin.configserver.SslConfigServerApiImpl) NodeMessageResponse(com.yahoo.vespa.hosted.node.admin.configserver.noderepository.bindings.NodeMessageResponse) UpdateNodeAttributesResponse(com.yahoo.vespa.hosted.node.admin.configserver.noderepository.bindings.UpdateNodeAttributesResponse) Collections(java.util.Collections) PrefixLogger(com.yahoo.vespa.hosted.node.admin.util.PrefixLogger) HttpException(com.yahoo.vespa.hosted.node.admin.configserver.HttpException) GetAclResponse(com.yahoo.vespa.hosted.node.admin.configserver.noderepository.bindings.GetAclResponse) ContainerAclSpec(com.yahoo.vespa.hosted.node.admin.ContainerAclSpec)

Example 27 with Node

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

the class NodeAgentImpl method shouldRemoveContainer.

private Optional<String> shouldRemoveContainer(ContainerNodeSpec nodeSpec, Container existingContainer) {
    final Node.State nodeState = nodeSpec.nodeState;
    if (nodeState == Node.State.dirty || nodeState == Node.State.provisioned) {
        return Optional.of("Node in state " + nodeState + ", container should no longer be running");
    }
    if (nodeSpec.wantedDockerImage.isPresent() && !nodeSpec.wantedDockerImage.get().equals(existingContainer.image)) {
        return Optional.of("The node is supposed to run a new Docker image: " + existingContainer + " -> " + nodeSpec.wantedDockerImage.get());
    }
    if (!existingContainer.state.isRunning()) {
        return Optional.of("Container no longer running");
    }
    ContainerResources wantedContainerResources = ContainerResources.from(nodeSpec.minCpuCores, nodeSpec.minMainMemoryAvailableGb);
    if (!wantedContainerResources.equals(existingContainer.resources)) {
        return Optional.of("Container should be running with different resource allocation, wanted: " + wantedContainerResources + ", actual: " + existingContainer.resources);
    }
    if (containerState == STARTING)
        return Optional.of("Container failed to start");
    return Optional.empty();
}
Also used : Node(com.yahoo.vespa.hosted.provision.Node) ContainerResources(com.yahoo.vespa.hosted.dockerapi.ContainerResources)

Example 28 with Node

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

the class AclProvisioningTest method trusted_nodes_for_docker_hosts_nodes_in_zone_application.

@Test
public void trusted_nodes_for_docker_hosts_nodes_in_zone_application() {
    // use same id for both allocate calls below
    ApplicationId applicationId = tester.makeApplicationId();
    List<Node> configServers = setConfigServers("cfg1:1234,cfg2:1234,cfg3:1234");
    // Populate repo
    tester.makeReadyNodes(2, "default", NodeType.host);
    // Allocate 2 Docker hosts
    List<Node> activeDockerHostNodes = allocateNodes(NodeType.host, applicationId);
    assertEquals(2, activeDockerHostNodes.size());
    // Check trusted nodes for all nodes
    activeDockerHostNodes.forEach(node -> {
        System.out.println("Checking node " + node);
        List<NodeAcl> nodeAcls = tester.nodeRepository().getNodeAcls(node, false);
        assertAcls(Arrays.asList(activeDockerHostNodes, configServers), dockerBridgeNetwork, nodeAcls);
    });
}
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 29 with Node

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

the class AclProvisioningTest method trusted_nodes_for_proxy.

@Test
public void trusted_nodes_for_proxy() {
    List<Node> configServers = setConfigServers("cfg1:1234,cfg2:1234,cfg3:1234");
    // Populate repo
    tester.makeReadyNodes(10, "default");
    tester.makeReadyNodes(3, "default", NodeType.proxy);
    // Deploy zone application
    ApplicationId zoneApplication = tester.makeApplicationId();
    allocateNodes(Capacity.fromRequiredNodeType(NodeType.proxy), zoneApplication);
    // Get trusted nodes for first proxy node
    List<Node> proxyNodes = tester.nodeRepository().getNodes(zoneApplication);
    Node node = proxyNodes.get(0);
    List<NodeAcl> nodeAcls = tester.nodeRepository().getNodeAcls(node, false);
    // Trusted nodes is all config servers and all proxy nodes
    assertAcls(Arrays.asList(proxyNodes, configServers), nodeAcls);
}
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 30 with Node

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

the class AclProvisioningTest method trusted_nodes_for_allocated_node.

@Test
public void trusted_nodes_for_allocated_node() {
    List<Node> configServers = setConfigServers("cfg1:1234,cfg2:1234,cfg3:1234");
    // Populate repo
    tester.makeReadyNodes(10, "default");
    List<Node> dockerHost = tester.makeReadyNodes(1, "default", NodeType.host);
    tester.makeReadyDockerNodes(1, "default", dockerHost.get(0).id());
    List<Node> proxyNodes = tester.makeReadyNodes(3, "default", NodeType.proxy);
    // Allocate 2 nodes
    List<Node> activeNodes = allocateNodes(2);
    assertEquals(2, activeNodes.size());
    // Get trusted nodes for the first active node
    Node node = activeNodes.get(0);
    List<NodeAcl> nodeAcls = tester.nodeRepository().getNodeAcls(node, false);
    // Trusted nodes is active nodes in same application, proxy nodes and config servers
    assertAcls(Arrays.asList(activeNodes, proxyNodes, configServers, dockerHost), nodeAcls);
}
Also used : Node(com.yahoo.vespa.hosted.provision.Node) NodeAcl(com.yahoo.vespa.hosted.provision.node.NodeAcl) 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