I don't know how the fabricat8's Kubernetes client works, but looking at the source
code of "addProvisionedSlave" method here:
https://github.com/jenkinsci/kubernetes-plugin/blob/kubernetes-0.10/src/main/java/org/csanchez/jenkins/plugins/kubernetes/KubernetesCloud.java
I was wandering if this could be a racing condition. Perhaps fabricat8's client does
not return any pod until it is actually ready (started). If so, this might explain why
the Container Capacity is not respected. The sequence of events could be like this:
- Jenkins wants to create a slave pod. Container capacity is not exceeded.
- The pod is being deployed to Kubernetes (it is starting).
- Jenkins wants to create another pod, it asks the fabricat8's client if there are any slave pods running.
- fabricat8's client responds that there are no pods (because the pod from step (2) is still being deployed (it is not running yet)).
- Jenkins creates another pod, effectively exceeding Container Capacity setting.
Is this reasonable?
BTW, I have switched to Kubernetes CI Plugin. That plugin requires a bit more knowledge about Kubernetes but is more flexible and behaves more correctly in my experience. Specifically, it better respects configured concurrent container count.