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

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

Open
3 tasks done
ericcitaire opened this issue Nov 4, 2020 · 1 comment · May be fixed by #971
Open
3 tasks done
Labels
bug An issue reporting a bug or a PR fixing one.

Comments

@ericcitaire
Copy link
Contributor

ericcitaire commented Nov 4, 2020

  • docker-plugin version : 1.2.1
  • jenkins version : 2.249.2
  • docker engine version : 19.03.13

In com.nirima.jenkins.plugins.docker.DockerCloud in canAddProvisionedSlave(), 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?

@pjdarton
Copy link
Member

pjdarton commented Nov 4, 2020

Yup, you're right - using the image name (only) is insufficiently-unique to count templates.
FYI it also gets confused when jobs specify their own job-specific template.
...and this false assumption is also made when the code tries to count the number of containers "under construction" too (which it tries to keep track of in order to reduce the amount of over-provisioning, as Jenkins keeps asking for more until they've come online, at which point we might have lots "under contruction" and get an excess).
i.e. This bug has been around for a long long time and nobody's (yet) plucked up the courage to fix it.

It might be easier these days than it used to be - now we have template names, which could be used to help differentiate ... except we don't insist folks set them so they can end up all looking the same that way too.

TL;DR: Yup, it's a bug. A PR to fix it would be welcomed.

@pjdarton pjdarton added the bug An issue reporting a bug or a PR fixing one. label Apr 27, 2022
Rikoshu pushed a commit to GEBIT/docker-plugin that referenced this issue Jun 1, 2023
@cpfeiffer cpfeiffer linked a pull request Jun 1, 2023 that will close this issue
6 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug An issue reporting a bug or a PR fixing one.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants