Skip to content

Commit

Permalink
Make Slave 🠦 Jenkins conn. timeout configurable
Browse files Browse the repository at this point in the history
For certain slaves, there might be a need to perform some runtime
configuration/steps after getting scheduled, but before starting the
jenkins job. The default timeout of 100s might not be sufficient for
such a scenario. To cater to this use case, this patch introduces the
ability to configure the slave to jenkins connection timeout, defaulting
to 100s for backwards compatibility.
  • Loading branch information
nehaljwani committed Feb 26, 2017
1 parent 6d6083d commit 5b42e77
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -697,6 +697,8 @@ public Node call() throws Exception {
throw new IllegalStateException("Container is not running after " + j + " attempts, status: " + status);
}

j = t.getSlaveConnectTimeout();

// now wait for slave to be online
for (; i < j; i++) {
if (slave.getComputer() == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ public class PodTemplate extends AbstractDescribableImpl<PodTemplate> implements

private int instanceCap = Integer.MAX_VALUE;

private int slaveConnectTimeout = 100;

private int idleMinutes;

private String label;
Expand Down Expand Up @@ -202,6 +204,18 @@ public int getInstanceCap() {
return instanceCap;
}

public void setSlaveConnectTimeout(int slaveConnectTimeout) {
if (slaveConnectTimeout < 0) {
this.slaveConnectTimeout = 0;
} else {
this.slaveConnectTimeout = slaveConnectTimeout;
}
}

public int getSlaveConnectTimeout() {
return slaveConnectTimeout;
}

@DataBoundSetter
public void setInstanceCapStr(String instanceCapStr) {
if (StringUtils.isBlank(instanceCapStr)) {
Expand All @@ -219,6 +233,19 @@ public String getInstanceCapStr() {
}
}

@DataBoundSetter
public void setSlaveConnectTimeoutStr(String slaveConnectTimeoutStr) {
if (StringUtils.isBlank(slaveConnectTimeoutStr)) {
setSlaveConnectTimeout(100); // default
} else {
setSlaveConnectTimeout(Integer.parseInt(slaveConnectTimeoutStr));
}
}

public String getSlaveConnectTimeoutStr() {
return String.valueOf(slaveConnectTimeout);
}

public void setIdleMinutes(int i) {
this.idleMinutes = i;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@
<f:textbox/>
</f:entry>

<f:entry field="slaveConnectTimeoutStr" title="${%Timeout in seconds for slave 🡒 jenkins conn.}">
<f:textbox/>
</f:entry>

<f:entry title="${%Annotations}" description="${%List of annotations to set in slave pod}" field="annotations">
<f:repeatableHeteroProperty field="annotations" hasHeader="true" addCaption="Add Annotation"
deleteCaption="Delete annotation Variable" />
Expand Down

0 comments on commit 5b42e77

Please sign in to comment.