Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add --noReconnectAfter 1d option when available in the agent image. #1553

Merged
merged 6 commits into from
May 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@
import java.util.regex.Pattern;
import java.util.stream.Collectors;
import jenkins.model.Jenkins;
import jenkins.util.SystemProperties;
import org.apache.commons.lang.StringUtils;
import org.csanchez.jenkins.plugins.kubernetes.model.TemplateEnvVar;
import org.csanchez.jenkins.plugins.kubernetes.pipeline.PodTemplateStepExecution;
Expand Down Expand Up @@ -100,6 +101,8 @@ public class PodTemplateBuilder {
public static final Pattern FROM_DIRECTIVE = Pattern.compile("^FROM (.*)$");

public static final String LABEL_KUBERNETES_CONTROLLER = "kubernetes.jenkins.io/controller";
static final String NO_RECONNECT_AFTER_TIMEOUT =
SystemProperties.getString(PodTemplateBuilder.class.getName() + ".noReconnectAfter", "1d");

@SuppressFBWarnings(value = "MS_SHOULD_BE_FINAL", justification = "tests")
@Restricted(NoExternalUse.class)
Expand Down Expand Up @@ -446,6 +449,7 @@ private Map<String, EnvVar> jnlpEnvVars(String workingDir) {
env.put("JENKINS_PROTOCOLS", "JNLP4-connect");
env.put("JENKINS_INSTANCE_IDENTITY", tcpSlaveAgentListener.getIdentityPublicKey());
}
env.put("REMOTING_OPTS", "-noReconnectAfter " + NO_RECONNECT_AFTER_TIMEOUT);
}
Map<String, EnvVar> envVarsMap = new HashMap<>();

Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
FROM jenkins/inbound-agent:3206.vb_15dcf73f6a_9-2
FROM jenkins/inbound-agent:3248.v65ecb_254c298-2
Original file line number Diff line number Diff line change
Expand Up @@ -480,6 +480,7 @@ private void validateJnlpContainer(Container jnlp, KubernetesSlave slave, boolea
envVars.add(new EnvVar("JENKINS_NAME", AGENT_NAME, null));
envVars.add(new EnvVar("JENKINS_AGENT_NAME", AGENT_NAME, null));
envVars.add(new EnvVar("JENKINS_AGENT_WORKDIR", ContainerTemplate.DEFAULT_WORKING_DIR, null));
envVars.add(new EnvVar("REMOTING_OPTS", "-noReconnectAfter " + NO_RECONNECT_AFTER_TIMEOUT, null));
} else {
assertThat(jnlp.getArgs(), empty());
}
Expand Down