Skip to content
This repository was archived by the owner on May 10, 2024. It is now read-only.

provide a nonempty node set in scope #140

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ private SortField<?> getSortingExpression() {
* @return Number of nodes to consider
*/
private int getLimit(final int podCnt) {
return (int) Math.ceil(LIMIT_TUNE_DEFAULT * podCnt);
return podCnt == 0 ? 1 : (int) Math.ceil(LIMIT_TUNE_DEFAULT * podCnt);
}

/**
Expand Down
29 changes: 29 additions & 0 deletions k8s-scheduler/src/test/java/com/vmware/dcm/ScopeTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,35 @@ public void testPodTolerations() {
assertTrue(scopedNodes.containsAll(randNodes.stream().map(x -> "n" + x).collect(Collectors.toSet())));
}

@Test
public void testEmptyPodBatch() {
final DBConnectionPool dbConnectionPool = new DBConnectionPool();
final List<String> policies = Policies.getInitialPlacementPolicies();
final NodeResourceEventHandler nodeResourceEventHandler = new NodeResourceEventHandler(dbConnectionPool);
final PodEventsToDatabase eventHandler = new PodEventsToDatabase(dbConnectionPool);
final PodResourceEventHandler handler = new PodResourceEventHandler(eventHandler::handle);

final int numNodes = 10;
for (int i = 0; i < numNodes; i++) {
final Node node = newNode("n" + i, Collections.emptyMap(), Collections.emptyList());
nodeResourceEventHandler.onAddSync(node);

// Add one system pod per node
final String podName = "system-pod-n" + i;
final Pod pod = newPod(podName, "Running");
pod.getSpec().setNodeName("n" + i);
handler.onAddSync(pod);
}

// Don't add any pending pods

final Scheduler scheduler = new Scheduler.Builder(dbConnectionPool)
.setInitialPlacementPolicies(policies)
.setScopedInitialPlacement(true)
.setDebugMode(true).build();
scheduler.initialPlacement();
}

/*
* E2E test with scheduler:
* Test if Scope limits candidate nodes according to spare resources
Expand Down