Skip to content
Merged
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
16 changes: 15 additions & 1 deletion core/src/main/java/hudson/model/queue/MappingWorksheet.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@
import hudson.model.Queue.Task;
import hudson.model.labels.LabelAssignmentAction;
import hudson.security.ACL;
import hudson.slaves.DumbSlave;
import java.time.Duration;
import java.util.AbstractList;
import java.util.ArrayList;
import java.util.Collection;
Expand Down Expand Up @@ -330,15 +332,27 @@
this.item = item;

// group executors by their computers
boolean someNonCloud = false;
Map<Computer, List<ExecutorSlot>> j = new HashMap<>();
for (ExecutorSlot o : offers) {
Computer c = o.getExecutor().getOwner();
if (!someNonCloud) {
Node n = c.getNode();
if (n == null || n instanceof DumbSlave) {

Check warning on line 341 in core/src/main/java/hudson/model/queue/MappingWorksheet.java

View check run for this annotation

ci.jenkins.io / Code Coverage

Partially covered line

Line 341 is only partially covered, one branch is missing
someNonCloud = true;
}
}
List<ExecutorSlot> l = j.computeIfAbsent(c, k -> new ArrayList<>());
l.add(o);
}

{ // take load prediction into account and reduce the available executor pool size accordingly
if (j.isEmpty()) {
LOGGER.fine(() -> "nothing to consider for " + item);
} else if (!someNonCloud) {
LOGGER.fine(() -> "only cloud agents to consider for " + item + ": " + offers);
} else { // take load prediction into account and reduce the available executor pool size accordingly
long duration = item.task.getEstimatedDuration();
LOGGER.fine(() -> "for " + item + " taking " + Duration.ofMillis(duration) + " considering " + offers);
if (duration > 0) {
long now = System.currentTimeMillis();
for (Map.Entry<Computer, List<ExecutorSlot>> e : j.entrySet()) {
Expand Down
3 changes: 2 additions & 1 deletion test/src/test/java/hudson/model/queue/LoadPredictorTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
import hudson.model.Queue.JobOffer;
import hudson.model.Queue.Task;
import hudson.model.Queue.WaitingItem;
import hudson.slaves.DumbSlave;
import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.Collection;
Expand Down Expand Up @@ -106,7 +107,7 @@ private JobOffer createMockOffer(Executor e) {
}

private Computer createMockComputer(int nExecutors) throws Exception {
Node n = mock(Node.class);
Node n = mock(DumbSlave.class);
Computer c = mock(Computer.class);
when(c.getNode()).thenReturn(n);

Expand Down
Loading