Skip to content

Commit

Permalink
Merge pull request #422 from mbarbero/master
Browse files Browse the repository at this point in the history
Improve labels and help text for cloud and pod templates cap
  • Loading branch information
carlossg authored Feb 27, 2019
2 parents 8ce86d3 + 298512d commit deef5cc
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -511,6 +511,13 @@ private boolean addProvisionedSlave(@Nonnull PodTemplate template, @CheckForNull
.collect(Collectors.toList());
}

if (allActiveSlavePods != null && containerCap <= allActiveSlavePods.size() + scheduledCount) {
LOGGER.log(Level.INFO,
"Maximum number of concurrently running agent pods ({0}) reached for Kubernetes Cloud {4}, not provisioning: {1} running or pending in namespace {2} with Kubernetes labels {3}",
new Object[] { containerCap, allActiveSlavePods.size() + scheduledCount, templateNamespace, getLabels(), name });
return false;
}

Map<String, String> labelsMap = new HashMap<>(this.getLabels());
labelsMap.putAll(template.getLabelsMap());
PodList templateSlaveList = client.pods().inNamespace(templateNamespace).withLabels(labelsMap).list();
Expand All @@ -521,19 +528,11 @@ private boolean addProvisionedSlave(@Nonnull PodTemplate template, @CheckForNull
.filter(x -> x.getStatus().getPhase().toLowerCase().matches("(running|pending)"))
.collect(Collectors.toList());
}

if (allActiveSlavePods != null && containerCap <= allActiveSlavePods.size() + scheduledCount) {
LOGGER.log(Level.INFO,
"Total container cap of {0} reached, not provisioning: {1} running or pending in namespace {2} with Kubernetes labels {3}",
new Object[] { containerCap, allActiveSlavePods.size() + scheduledCount, templateNamespace, getLabels() });
return false;
}

if (activeTemplateSlavePods != null && allActiveSlavePods != null && template.getInstanceCap() <= activeTemplateSlavePods.size() + scheduledCount) {
LOGGER.log(Level.INFO,
"Template instance cap of {0} reached for template {1}, not provisioning: {2} running or pending in namespace {3} with label \"{4}\" and Kubernetes labels {5}",
"Maximum number of concurrently running agent pods ({0}) reached for template {1} in Kubernetes Cloud {6}, not provisioning: {2} running or pending in namespace {3} with label \"{4}\" and Kubernetes labels {5}",
new Object[] { template.getInstanceCap(), template.getName(), activeTemplateSlavePods.size() + scheduledCount,
templateNamespace, label == null ? "" : label.toString(), labelsMap });
templateNamespace, label == null ? "" : label.toString(), labelsMap, name });
return false;
}
return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
<f:textbox default="15"/>
</f:entry>

<f:entry title="${%Container Cap}" field="containerCapStr">
<f:entry title="${%Concurrency Limit}" field="containerCapStr">
<f:textbox default="10"/>
</f:entry>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ Jenkins\ URL=Jenkins \u5730\u5740
Jenkins\ tunnel=Jenkins \u901A\u9053
Connection\ Timeout\ (seconds)=\u8FDE\u63A5\u8D85\u65F6\uFF08\u79D2\uFF09
Read\ Timeout\ (seconds)=\u8BFB\u53D6\u8D85\u65F6\uFF08\u79D2\uFF09
Container\ Cap=\u5BB9\u5668\u6570\u91CF
Concurrency\ Limit=\u5BB9\u5668\u6570\u91CF
Apply\ cap\ only\ on\ alive\ pods=\u7528\u4E8E\u6D3B\u8DC3\u7684 Pod
Max\ connections\ to\ Kubernetes\ API=\u8FDE\u63A5 Kubernetes API \u7684\u6700\u5927\u8FDE\u63A5\u6570
Container\ Cleanup\ Timeout\ (minutes)=\u5BB9\u5668\u8D85\u65F6\uFF08\u5206\uFF09
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<div>
The maximum number of concurrently running agent containers that Kubernetes is allowed to run.
If set to empty it means no limit. Set to 0 means no containers will be started.
The maximum number of concurrently running agent pods that are permitted in this Kubernetes Cloud.
If set to empty it means no limit. Set to 0 means no pod will ever be started.
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
deleteCaption="${%Delete Volume}" />
</f:entry>

<f:entry field="instanceCapStr" title="${%Max number of instances}"
<f:entry field="instanceCapStr" title="${%Concurrency Limit}"
help="/plugin/kubernetes/help/instanceCap.html">
<f:textbox/>
</f:entry>
Expand Down
4 changes: 3 additions & 1 deletion src/main/webapp/help/instanceCap.html
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
<div>
Max number of containers to start from this template. If set to empty or negative number it means no limit.
The maximum number of concurrently running agent pods created from this template that are permitted in the Kubernetes Cloud.
The number of running agents will never exceed the global concurrency limit sets at the Cloud Configuration level.
If set to empty or negative number it means no limit.
</div>

0 comments on commit deef5cc

Please sign in to comment.