jenkinsci / jenkinsci/docker-plugin

Wrong calculation of running Template agents when using the same image on multiple templates

Open
#816 1 comment 1 reaction 0 assignees View on GitHub
Dominant language
Java
Stars
498
Forks
324
Avg merge
1d 2h
Merged PRs (30d)
2

Description

- [X] docker-plugin version : **1.2.1**
- [X] jenkins version : **2.249.2**
- [X] docker engine version : **19.03.13**

In [`com.nirima.jenkins.plugins.docker.DockerCloud` in `canAddProvisionedSlave()`](https://github.com/jenkinsci/docker-plugin/blob/c3a38d7034132cb407832a4ae0372f44339a2b03/src/main/java/com/nirima/jenkins/plugins/docker/DockerCloud.java#L650), an estimation of running template agents is done.

This is done by counting the running containers using the same image as the template image, which is wrong since multiple templates of the same cloud can use the same Docker image.

In my case, I have 2 templates (A and B) with the same Docker image, but different container capacities (2 and 5) and different agent labels (for limiting the builds). When the running containers count equals the container capacity of template A (cap=2), `canAddProvisionedSlave()` also returns `false` for template B (cap=5), even though it has no running agents and should have enough capacity to provision up to 5 agents.

It may be fixed by adding a template label to each container and add a filter on this label to count running template agents?

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.