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();
}
}
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();
}
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);
});
}
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);
}
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);
}
Aggregations