mirror of
https://github.com/jenkinsci/jenkins.git
synced 2026-11-16 21:42:27 +00:00
Allow the administrator to yank out dead executors.
This commit is contained in:
1 parent
ee59683bf4
commit
0d5ed5a8c7
5 files changed
+75
-1
No files matched your search
@@ -685,10 +685,23 @@ public /*transient*/ abstract class Computer extends Actionable implements Acces
|
||||
*/
|
||||
/*package*/ synchronized void removeExecutor(Executor e) {
|
||||
executors.remove(e);
|
||||
if(executors.isEmpty())
|
||||
if(!isAlive())
|
||||
Hudson.getInstance().removeComputer(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if any of the executors are functioning.
|
||||
*
|
||||
* Note that if an executor dies, we'll leave it in {@link #executors} until
|
||||
* the administrator yanks it out, so that we can see why it died.
|
||||
*/
|
||||
private boolean isAlive() {
|
||||
for (Executor e : executors)
|
||||
if (e.isAlive())
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Interrupt all {@link Executor}s.
|
||||
*/
|
||||
|
||||
@@ -33,6 +33,8 @@ import hudson.model.queue.WorkUnit;
|
||||
import hudson.util.TimeUnit2;
|
||||
import hudson.util.InterceptingProxy;
|
||||
import hudson.security.ACL;
|
||||
import org.kohsuke.stapler.HttpResponse;
|
||||
import org.kohsuke.stapler.HttpResponses;
|
||||
import org.kohsuke.stapler.StaplerRequest;
|
||||
import org.kohsuke.stapler.StaplerResponse;
|
||||
import org.kohsuke.stapler.export.ExportedBean;
|
||||
@@ -77,6 +79,8 @@ public class Executor extends Thread implements ModelObject {
|
||||
|
||||
private Throwable causeOfDeath;
|
||||
|
||||
private boolean induceDeath;
|
||||
|
||||
public Executor(Computer owner, int n) {
|
||||
super("Executor #"+n+" for "+owner.getDisplayName());
|
||||
this.owner = owner;
|
||||
@@ -107,6 +111,7 @@ public class Executor extends Thread implements ModelObject {
|
||||
// sometime an interrupt aborts a build but without clearing the flag.
|
||||
// see issue #1583
|
||||
if (Thread.interrupted()) continue;
|
||||
if (induceDeath) throw new ThreadDeath();
|
||||
|
||||
SubTask task;
|
||||
try {
|
||||
@@ -167,6 +172,14 @@ public class Executor extends Thread implements ModelObject {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* For testing only. Simulate a fatal unexpected failure.
|
||||
*/
|
||||
public void killHard() {
|
||||
induceDeath = true;
|
||||
interrupt();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if we should keep going.
|
||||
*/
|
||||
@@ -361,6 +374,17 @@ public class Executor extends Thread implements ModelObject {
|
||||
rsp.forwardToPreviousPage(req);
|
||||
}
|
||||
|
||||
/**
|
||||
* Throws away this executor and get a new one.
|
||||
*/
|
||||
public HttpResponse doYank() {
|
||||
Hudson.getInstance().checkPermission(Hudson.ADMINISTER);
|
||||
if (isAlive())
|
||||
throw new Failure("Can't yank a live executor");
|
||||
owner.removeExecutor(this);
|
||||
return HttpResponses.redirectViaContextPath("/");
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the current user has a permission to stop this build.
|
||||
*/
|
||||
|
||||
Reference in new issue
Block a user