Skip to content

Commit

Permalink
Prevent premature removal of agent when Jenkins is in quiet mode
Browse files Browse the repository at this point in the history
  • Loading branch information
David-Villeneuve committed Nov 5, 2021
1 parent d6e0dc1 commit 630f506
Showing 1 changed file with 2 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import hudson.model.ExecutorListener;
import hudson.model.Queue;
import hudson.slaves.RetentionStrategy;
import jenkins.model.Jenkins;

public class DockerSwarmAgentRetentionStrategy extends RetentionStrategy<DockerSwarmComputer>
implements ExecutorListener {
Expand All @@ -45,7 +46,7 @@ public long check(@Nonnull DockerSwarmComputer c) {
final long connectTime = System.currentTimeMillis() - c.getConnectTime();
final long idleTime = System.currentTimeMillis() - c.getIdleStartMilliseconds();
final boolean isTimeout = connectTime > timeout && idleTime > timeout;
if (isTimeout && (!isTaskAccepted || isTaskCompleted)) {
if (isTimeout && (!isTaskAccepted || isTaskCompleted ) && !Jenkins.getInstance().isQuietingDown()) {
LOGGER.log(Level.INFO, "Disconnecting due to idle {0}", c.getName());
done(c);
}
Expand Down

0 comments on commit 630f506

Please sign in to comment.