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