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

Prevent over-provisioning #622

Merged
merged 1 commit into from
Feb 22, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,22 @@ public synchronized Collection<NodeProvisioner.PlannedNode> provision(final Labe
final List<DockerTemplate> templates = getTemplates(label);
int remainingWorkload = numberOfExecutorsRequired;

// Take account of the executors that will result from the containers which we
// are already committed to starting but which have yet to be given to Jenkins
for ( final DockerTemplate t : templates ) {
final int numberOfContainersInProgress = countContainersInProgress(t);
final int numberOfExecutorsInProgress = t.getNumExecutors() * numberOfContainersInProgress;
remainingWorkload -= numberOfExecutorsInProgress;
}
if ( remainingWorkload != numberOfExecutorsRequired ) {
final int numberOfExecutorsInProgress = numberOfExecutorsRequired - remainingWorkload;
if( remainingWorkload<=0 ) {
LOGGER.info("Not provisioning additional slaves for {}; we have {} executors being started already", label, numberOfExecutorsInProgress);
} else {
LOGGER.info("Only provisioning {} slaves for {}; we have {} executors being started already", remainingWorkload, label, numberOfExecutorsInProgress);
}
}

while (remainingWorkload > 0 && !templates.isEmpty()) {
final DockerTemplate t = templates.get(0); // get first

Expand Down