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