You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix: handle scaling properly when capacity_per_instance > 1 with docker job runners (#1313)
## Summary
This PR fixes a critical bug in the docker-autoscaler configuration
where the runner's job limit doesn't account for
`capacity_per_instance`, causing incorrect scaling behavior.
## Problem
When using `docker-autoscaler` with `capacity_per_instance > 1`, the
module sets the runner's job limit (`limit` field in config.toml) to
`max_jobs` without multiplying by `capacity_per_instance`. This causes
the GitLab Runner to miscalculate the number of instances needed.
### Example scenario:
- `max_jobs = 25` (intended max instances)
- `capacity_per_instance = 3` (jobs per instance)
- 50 jobs are queued
**Current behavior:**
- Runner job limit = 25
- Runner calculates: ceil(25 ÷ 3) = 9 instances max
- Only 9 instances are created, leaving jobs queued
**Expected behavior:**
- Runner job limit = 75 (25 × 3)
- Runner calculates: ceil(50 ÷ 3) = 17 instances
- Proper scaling up to 25 instances as configured
## Solution
The fix multiplies `max_jobs` by `capacity_per_instance` when setting
`runners_limit` for docker-autoscaler type runners.
```hcl
runners_limit = var.runner_worker.type == "docker-autoscaler" ?
var.runner_worker.max_jobs * var.runner_worker_docker_autoscaler.capacity_per_instance :
var.runner_worker.max_jobs
```
## Testing
Tested with:
- `max_jobs = 25`
- `capacity_per_instance = 3`
- Verified the runner config correctly shows `limit = 75`
- Confirmed ASG can now scale beyond 9 instances
Co-authored-by: Matthias Kay <matthias.kay@hlag.com>
0 commit comments