Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Display any Computer.terminatedBy in the build log #94

Merged
merged 3 commits into from
Jan 11, 2019
Merged
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 @@ -29,6 +29,7 @@
import hudson.security.ACLContext;
import hudson.security.AccessControlled;
import hudson.security.Permission;
import hudson.slaves.OfflineCause;
import hudson.slaves.WorkspaceList;
import java.io.IOException;
import java.io.PrintStream;
Expand Down Expand Up @@ -658,15 +659,16 @@ private static final class Callback extends BodyExecutionCallback.TailCall {
private final class PlaceholderExecutable implements ContinuableExecutable, AccessControlled {

@Override public void run() {
final TaskListener listener;
TaskListener listener = null;
Launcher launcher;
final Run<?, ?> r;
Computer computer = null;
try {
Executor exec = Executor.currentExecutor();
if (exec == null) {
throw new IllegalStateException("running task without associated executor thread");
}
Computer computer = exec.getOwner();
computer = exec.getOwner();
// Set up context for other steps inside this one.
Node node = computer.getNode();
if (node == null) {
Expand Down Expand Up @@ -724,6 +726,17 @@ private final class PlaceholderExecutable implements ContinuableExecutable, Acce
LOGGER.log(FINE, "resuming {0}", cookie);
}
} catch (Exception x) {
if (computer != null) {
for (Computer.TerminationRequest tr : computer.getTerminatedBy()) {
x.addSuppressed(tr);
}
if (listener != null) {
OfflineCause oc = computer.getOfflineCause();
if (oc != null) {
listener.getLogger().println(computer.getDisplayName() + " was marked offline: " + oc);
}
}
}
context.onFailure(x);
return;
}
Expand All @@ -738,6 +751,7 @@ private final class PlaceholderExecutable implements ContinuableExecutable, Acce
assert runningTask.execution == null;
assert runningTask.launcher == null;
runningTask.launcher = launcher;
TaskListener _listener = listener;
runningTask.execution = new AsynchronousExecution() {
@Override public void interrupt(boolean forShutdown) {
if (forShutdown) {
Expand All @@ -753,7 +767,7 @@ private final class PlaceholderExecutable implements ContinuableExecutable, Acce
} else { // anomalous state; perhaps build already aborted but this was left behind; let user manually cancel executor slot
Executor thisExecutor = /* AsynchronousExecution. */getExecutor();
if (thisExecutor != null) {
thisExecutor.recordCauseOfInterruption(r, listener);
thisExecutor.recordCauseOfInterruption(r, _listener);
}
completed(null);
}
Expand Down