提交 c3a19670 编写于 作者: K Kohsuke Kawaguchi

[JENKINS-13564] make the method self-correcting

If for some reason the numExecutors field gets out of sync with executors.size() (for example this can happen if an executor swallowed an interrupt signal without properly processing it), then a further attempt to call setNumExecutors(n) results in a no-op.

Given that these things can get out of sync, a smarter thing to do is to always compare where we are (the "executors" variable) and where we'd like to be (numExecutors), and make corrective actions.

This particularly affects a zombie computer. The sequence to kill a Computer first involves waiting for all the executors to quit. If setNumExecutors(0) becomes no-op, a zombine computer never gets killed.
上级 18f394c1
......@@ -691,17 +691,18 @@ public /*transient*/ abstract class Computer extends Actionable implements Acces
}
private synchronized void setNumExecutors(int n) {
if(numExecutors==n) return; // no-op
int diff = n-numExecutors;
this.numExecutors = n;
int diff = executors.size()-n;
if(diff<0) {
if (diff>0) {
// we have too many executors
// send signal to all idle executors to potentially kill them off
for( Executor e : executors )
if(e.isIdle())
e.interrupt();
} else {
}
if (diff<0) {
// if the number is increased, add new ones
addNewExecutorIfNecessary();
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册