use of com.yahoo.config.provision.ClusterSpec in project vespa by vespa-engine.
the class ReservationExpirerTest method ensure_reservation_times_out.
@Test
public void ensure_reservation_times_out() {
ManualClock clock = new ManualClock();
NodeFlavors flavors = FlavorConfigBuilder.createDummies("default");
NodeRepository nodeRepository = new NodeRepository(flavors, curator, clock, Zone.defaultZone(), new MockNameResolver().mockAnyLookup(), new DockerImage("docker-registry.domain.tld:8080/dist/vespa"), true);
NodeRepositoryProvisioner provisioner = new NodeRepositoryProvisioner(nodeRepository, flavors, Zone.defaultZone());
List<Node> nodes = new ArrayList<>(2);
nodes.add(nodeRepository.createNode(UUID.randomUUID().toString(), UUID.randomUUID().toString(), Optional.empty(), flavors.getFlavorOrThrow("default"), NodeType.tenant));
nodes.add(nodeRepository.createNode(UUID.randomUUID().toString(), UUID.randomUUID().toString(), Optional.empty(), flavors.getFlavorOrThrow("default"), NodeType.tenant));
nodes.add(nodeRepository.createNode(UUID.randomUUID().toString(), UUID.randomUUID().toString(), Optional.empty(), flavors.getFlavorOrThrow("default"), NodeType.host));
nodes = nodeRepository.addNodes(nodes);
nodes = nodeRepository.setDirty(nodes, Agent.system, getClass().getSimpleName());
// Reserve 2 nodes
assertEquals(2, nodeRepository.getNodes(NodeType.tenant, Node.State.dirty).size());
nodeRepository.setReady(nodes, Agent.system, getClass().getSimpleName());
ApplicationId applicationId = new ApplicationId.Builder().tenant("foo").applicationName("bar").instanceName("fuz").build();
ClusterSpec cluster = ClusterSpec.request(ClusterSpec.Type.content, ClusterSpec.Id.from("test"), Version.fromString("6.42"), false);
provisioner.prepare(applicationId, cluster, Capacity.fromNodeCount(2), 1, null);
assertEquals(2, nodeRepository.getNodes(NodeType.tenant, Node.State.reserved).size());
// Reservation times out
// Reserved but not used time out
clock.advance(Duration.ofMinutes(14));
new ReservationExpirer(nodeRepository, clock, Duration.ofMinutes(10), new JobControl(nodeRepository.database())).run();
// Assert nothing is reserved
assertEquals(0, nodeRepository.getNodes(NodeType.tenant, Node.State.reserved).size());
List<Node> dirty = nodeRepository.getNodes(NodeType.tenant, Node.State.dirty);
assertEquals(2, dirty.size());
assertFalse(dirty.get(0).allocation().isPresent());
assertFalse(dirty.get(1).allocation().isPresent());
}
use of com.yahoo.config.provision.ClusterSpec in project vespa by vespa-engine.
the class NodeFailTester method withProxyApplication.
public static NodeFailTester withProxyApplication() {
NodeFailTester tester = new NodeFailTester();
tester.createReadyNodes(16, NodeType.proxy);
// Create application
Capacity allProxies = Capacity.fromRequiredNodeType(NodeType.proxy);
ClusterSpec clusterApp1 = ClusterSpec.request(ClusterSpec.Type.container, ClusterSpec.Id.from("test"), Version.fromString("6.42"), false);
tester.activate(app1, clusterApp1, allProxies);
assertEquals(16, tester.nodeRepository.getNodes(NodeType.proxy, Node.State.active).size());
Map<ApplicationId, MockDeployer.ApplicationContext> apps = new HashMap<>();
apps.put(app1, new MockDeployer.ApplicationContext(app1, clusterApp1, allProxies, 1));
tester.deployer = new MockDeployer(tester.provisioner, apps);
tester.serviceMonitor = new ServiceMonitorStub(apps, tester.nodeRepository);
tester.metric = new MetricsReporterTest.TestMetric();
tester.failer = tester.createFailer();
return tester;
}
use of com.yahoo.config.provision.ClusterSpec in project vespa by vespa-engine.
the class NodeRetirerTester method deployApp.
void deployApp(String tenantName, String applicationName, int[] flavorIds, int[] numNodes) {
final ApplicationId applicationId = ApplicationId.from(tenantName, applicationName, "default");
final List<MockDeployer.ClusterContext> clusterContexts = new ArrayList<>();
for (int i = 0; i < flavorIds.length; i++) {
Flavor flavor = flavors.get(flavorIds[i]);
ClusterSpec cluster = ClusterSpec.request(ClusterSpec.Type.container, ClusterSpec.Id.from("cluster-" + i), Version.fromString("6.99"), false);
Capacity capacity = Capacity.fromNodeCount(numNodes[i], Optional.of(flavor.name()), false);
// If the number of node the app wants is divisible by 2, make it into 2 groups, otherwise as 1
int numGroups = numNodes[i] % 2 == 0 ? 2 : 1;
clusterContexts.add(new MockDeployer.ClusterContext(applicationId, cluster, capacity, numGroups));
}
apps.put(applicationId, new MockDeployer.ApplicationContext(applicationId, clusterContexts));
deployer.deployFromLocalActive(applicationId, Duration.ZERO).get().activate();
}
use of com.yahoo.config.provision.ClusterSpec in project vespa by vespa-engine.
the class RetiredExpirerTest method ensure_retired_groups_time_out.
@Test
public void ensure_retired_groups_time_out() {
createReadyNodes(8, nodeRepository, nodeFlavors);
createHostNodes(4, nodeRepository, nodeFlavors);
ApplicationId applicationId = ApplicationId.from(TenantName.from("foo"), ApplicationName.from("bar"), InstanceName.from("fuz"));
ClusterSpec cluster = ClusterSpec.request(ClusterSpec.Type.content, ClusterSpec.Id.from("test"), Version.fromString("6.42"), false);
activate(applicationId, cluster, 8, 8, provisioner);
activate(applicationId, cluster, 2, 2, provisioner);
assertEquals(8, nodeRepository.getNodes(applicationId, Node.State.active).size());
assertEquals(0, nodeRepository.getNodes(applicationId, Node.State.inactive).size());
// Cause inactivation of retired nodes
// Retire period spent
clock.advance(Duration.ofHours(30));
MockDeployer deployer = new MockDeployer(provisioner, Collections.singletonMap(applicationId, new MockDeployer.ApplicationContext(applicationId, cluster, Capacity.fromNodeCount(2, Optional.of("default"), false), 1)));
createRetiredExpirer(deployer).run();
assertEquals(2, nodeRepository.getNodes(applicationId, Node.State.active).size());
assertEquals(6, nodeRepository.getNodes(applicationId, Node.State.inactive).size());
assertEquals(1, deployer.redeployments);
// inactivated nodes are not retired
for (Node node : nodeRepository.getNodes(applicationId, Node.State.inactive)) assertFalse(node.allocation().get().membership().retired());
}
use of com.yahoo.config.provision.ClusterSpec in project vespa by vespa-engine.
the class Preparer method prepare.
/**
* Ensure sufficient nodes are reserved or active for the given application and cluster
*
* @return the list of nodes this cluster will have allocated if activated
*/
// Note: This operation may make persisted changes to the set of reserved and inactive nodes,
// but it may not change the set of active nodes, as the active nodes must stay in sync with the
// active config model which is changed on activate
public List<Node> prepare(ApplicationId application, ClusterSpec cluster, NodeSpec requestedNodes, int wantedGroups) {
List<Node> surplusNodes = findNodesInRemovableGroups(application, cluster, wantedGroups);
MutableInteger highestIndex = new MutableInteger(findHighestIndex(application, cluster));
List<Node> acceptedNodes = new ArrayList<>();
for (int groupIndex = 0; groupIndex < wantedGroups; groupIndex++) {
ClusterSpec clusterGroup = cluster.with(Optional.of(ClusterSpec.Group.from(groupIndex)));
List<Node> accepted = groupPreparer.prepare(application, clusterGroup, requestedNodes.fraction(wantedGroups), surplusNodes, highestIndex, spareCount);
replace(acceptedNodes, accepted);
}
moveToActiveGroup(surplusNodes, wantedGroups, cluster.group());
replace(acceptedNodes, retire(surplusNodes));
return acceptedNodes;
}
Aggregations