Skip to content

Commit

Permalink
Restrict JnlpSlaveRestarterInstaller to DumbSlave (#7693)
Browse files Browse the repository at this point in the history
  • Loading branch information
Vlatombe authored Mar 17, 2023
1 parent fd0e8cb commit 28f592d
Showing 1 changed file with 11 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import hudson.remoting.EngineListenerAdapter;
import hudson.remoting.VirtualChannel;
import hudson.slaves.ComputerListener;
import hudson.slaves.DumbSlave;
import java.io.IOException;
import java.io.Serializable;
import java.util.ArrayList;
Expand All @@ -25,17 +26,24 @@
* Actual agent restart logic.
*
* <p>
* Use {@link ComputerListener} to install {@link EngineListener}, which in turn gets executed when
* the agent gets disconnected.
* Use {@link ComputerListener} to install {@link EngineListener} on {@link hudson.model.Computer} instances tied to {@link DumbSlave},
* which in turn gets executed when the agent gets disconnected.
*
* @author Kohsuke Kawaguchi
*/
@Extension
public class JnlpSlaveRestarterInstaller extends ComputerListener implements Serializable {
/**
* To force installer to run on all agents, set this system property to true.
*/
private static final boolean FORCE_INSTALL = Boolean.getBoolean(JnlpSlaveRestarterInstaller.class.getName() + ".forceInstall");

@SuppressFBWarnings(value = "RV_RETURN_VALUE_IGNORED_BAD_PRACTICE", justification = "method signature does not permit plumbing through the return value")
@Override
public void onOnline(final Computer c, final TaskListener listener) throws IOException, InterruptedException {
Computer.threadPoolForRemoting.submit(new Install(c, listener));
if (FORCE_INSTALL || c.getNode() instanceof DumbSlave) {
Computer.threadPoolForRemoting.submit(new Install(c, listener));
}
}

private static class Install implements Callable<Void> {
Expand Down

0 comments on commit 28f592d

Please sign in to comment.