mirror of https://github.com/jenkinsci/jenkins.git
Define health check for `BindException` on enforced TCP port (#11145)
This commit is contained in:
parent
b1fe658d39
commit
9f200b11b6
|
@ -50,6 +50,7 @@ import java.util.Base64;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
import jenkins.AgentProtocol;
|
import jenkins.AgentProtocol;
|
||||||
|
import jenkins.health.HealthCheck;
|
||||||
import jenkins.model.Jenkins;
|
import jenkins.model.Jenkins;
|
||||||
import jenkins.model.identity.InstanceIdentityProvider;
|
import jenkins.model.identity.InstanceIdentityProvider;
|
||||||
import jenkins.security.stapler.StaplerAccessibleType;
|
import jenkins.security.stapler.StaplerAccessibleType;
|
||||||
|
@ -445,4 +446,14 @@ public final class TcpSlaveAgentListener extends Thread {
|
||||||
@SuppressFBWarnings(value = "MS_SHOULD_BE_FINAL", justification = "Accessible via System Groovy Scripts")
|
@SuppressFBWarnings(value = "MS_SHOULD_BE_FINAL", justification = "Accessible via System Groovy Scripts")
|
||||||
@Restricted(NoExternalUse.class)
|
@Restricted(NoExternalUse.class)
|
||||||
public static Integer CLI_PORT = SystemProperties.getInteger(TcpSlaveAgentListener.class.getName() + ".port");
|
public static Integer CLI_PORT = SystemProperties.getInteger(TcpSlaveAgentListener.class.getName() + ".port");
|
||||||
|
|
||||||
|
@Extension
|
||||||
|
public static final class EnforcedPortHealthCheck implements HealthCheck {
|
||||||
|
@Override
|
||||||
|
public boolean check() {
|
||||||
|
var j = Jenkins.get();
|
||||||
|
return !j.isSlaveAgentPortEnforced() || j.getSlaveAgentPort() <= 0 || j.getTcpSlaveAgentListener() != null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue