Skip to content

Commit

Permalink
Allowing FilePathDynamicContext to block waiting for an agent to re…
Browse files Browse the repository at this point in the history
…connect.

Not great since the CPS VM thread will only grant 5s.
Better would be to avoid unnecessary use of `StepContext.get(FilePath.class)`
(which implicitly requires a live `Channel`);
perhaps `FilePathRepresentation` should become an API.
Amends b65ff1c.
#180 (comment)
  • Loading branch information
jglick committed Apr 28, 2022
1 parent 79d4ff0 commit 8b08398
Showing 1 changed file with 13 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -62,24 +62,27 @@
FilePath f = FilePathUtils.find(r.slave, r.path);
if (f != null) {
LOGGER.log(Level.FINE, "serving {0}:{1}", new Object[] {r.slave, r.path});
return f;
} else {
IOException e = new IOException("Unable to create live FilePath for " + r.slave);
Computer c = Jenkins.get().getComputer(r.slave);
if (c != null) {
if (c != null && !c.isConnecting()) {
IOException e = new IOException("Unable to create live FilePath for " + r.slave);
for (Computer.TerminationRequest tr : c.getTerminatedBy()) {
e.addSuppressed(tr);
}
}
TaskListener listener = context.get(TaskListener.class);
if (listener != null) {
OfflineCause oc = c.getOfflineCause();
if (oc != null) {
listener.getLogger().println(c.getDisplayName() + " was marked offline: " + oc);
TaskListener listener = context.get(TaskListener.class);
if (listener != null) {
OfflineCause oc = c.getOfflineCause();
if (oc != null) {
listener.getLogger().println(c.getDisplayName() + " was marked offline: " + oc);
}
}
throw e;
}
throw e;
LOGGER.fine(() -> "Waiting to see if " + r.slave + " will come online");
Thread.sleep(500);
return get(context);
}
return f;
}

/**
Expand Down

0 comments on commit 8b08398

Please sign in to comment.