Skip to content

Commit

Permalink
ExecutorPickle should not reschedule anything until after `Queue.lo…
Browse files Browse the repository at this point in the history
…ad` (#184)
  • Loading branch information
jglick authored Nov 22, 2021
1 parent 7479b9b commit 08e8ce1
Showing 1 changed file with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import hudson.Extension;
import hudson.Main;
import hudson.Util;
import hudson.init.InitMilestone;
import hudson.model.Executor;
import hudson.model.Node;
import hudson.model.OneOffExecutor;
Expand Down Expand Up @@ -87,10 +88,14 @@ private ExecutorPickle(Executor executor) {
@Override public ListenableFuture<Executor> rehydrate(final FlowExecutionOwner owner) {
return new TryRepeatedly<Executor>(1, 0) {
long itemID;
long endTimeNanos = System.nanoTime() + TIMEOUT_WAITING_FOR_NODE_MILLIS*1000000;
long endTimeNanos;

@Override
protected Executor tryResolve() throws Exception {
if (Jenkins.get().getInitLevel() != InitMilestone.COMPLETED) {
LOGGER.fine(() -> "not going to schedule " + task + " yet because Jenkins has not yet completed startup");
return null;
}
Queue.Item item;
if (itemID == 0) { // Not scheduled yet
item = Queue.getInstance().schedule2(task, 0).getItem();
Expand All @@ -99,6 +104,7 @@ protected Executor tryResolve() throws Exception {
throw new IllegalStateException("queue refused " + task);
}
itemID = item.getId();
endTimeNanos = System.nanoTime() + TIMEOUT_WAITING_FOR_NODE_MILLIS*1000000;
LOGGER.log(Level.FINE, "{0} scheduled {1}", new Object[] {ExecutorPickle.this, item});
} else {
item = Queue.getInstance().getItem(itemID);
Expand Down

0 comments on commit 08e8ce1

Please sign in to comment.