提交 71ad43a1 编写于 作者: F fma1977 提交者: Kohsuke Kawaguchi

[FIXED JENKINS-13735]

Added test whether the currently checked slave computer actually can take the buildable item before flagging it as needed (avoids powering up and connecting to slaves for jobs they can't build).
上级 00a221d4
......@@ -55,6 +55,9 @@ Upcoming changes</a>
<!-- Record your changes in the trunk here. -->
<div id="trunk" style="display:none"><!--=TRUNK-BEGIN=-->
<ul class=image>
<li class=bug>
With 'on-demand' retention strategy, wrong slave can be started for jobs restricted to specific slave.
(<a href="https://issues.jenkins-ci.org/browse/JENKINS-13735">issue 13735</a>)
<li class=bug>
Fixed encoding handling in e-mail headers.
(<a href="https://github.com/jenkinsci/jenkins/pull/486">pull 486</a>)
......
......@@ -199,13 +199,16 @@ public abstract class RetentionStrategy<T extends Computer> extends AbstractDesc
for (Computer o : Jenkins.getInstance().getComputers()) {
if ((o.isOnline() || o.isConnecting()) && o.isPartiallyIdle()) {
final int idleExecutors = o.countIdle();
availableComputers.put(o, idleExecutors);
if (idleExecutors>0)
availableComputers.put(o, idleExecutors);
}
}
boolean needComputer = false;
long demandMilliseconds = 0;
for (Queue.BuildableItem item : Queue.getInstance().getBuildableItems()) {
// can any of the currently idle executors take this task?
// assume the answer is no until we can find such an executor
boolean needExecutor = true;
for (Computer o : Collections.unmodifiableSet(availableComputers.keySet())) {
if (o.getNode().canTake(item) == null) {
......@@ -213,12 +216,15 @@ public abstract class RetentionStrategy<T extends Computer> extends AbstractDesc
final int availableExecutors = availableComputers.remove(o);
if (availableExecutors > 1) {
availableComputers.put(o, availableExecutors - 1);
} else {
availableComputers.remove(o);
}
break;
}
}
if (needExecutor) {
// this 'item' cannot be built by any of the existing idle nodes, but it can be built by 'c'
if (needExecutor && c.getNode().canTake(item) == null) {
demandMilliseconds = System.currentTimeMillis() - item.buildableStartMilliseconds;
needComputer = demandMilliseconds > inDemandDelay * 1000 * 60 /*MINS->MILLIS*/;
break;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册