Skip to content

feat: drain run backlog back-to-back with a job capacity guard#42

Open
tfelix wants to merge 1 commit into
mainfrom
feature/BD-2525-improve-job-spawn-speed-on-run-controller
Open

feat: drain run backlog back-to-back with a job capacity guard#42
tfelix wants to merge 1 commit into
mainfrom
feature/BD-2525-improve-job-spawn-speed-on-run-controller

Conversation

@tfelix

@tfelix tfelix commented Jun 23, 2026

Copy link
Copy Markdown
Collaborator

The run-controller previously created at most one job per polling interval, so a backlog of runs drained at 1 run / interval. It also had no concurrency limit: it would claim a run, fail job creation when the namespace was full, and report the run as FAILED.

Process queued runs back-to-back each polling cycle until the backlog is empty, and gate fetching on a best-effort capacity check so we only claim runs we are fairly sure we can place:

  • Add maxConcurrentJobs config (default 20; negative = unlimited).
  • Count unfinished runner jobs (CountActiveJobs) and drain only up to the remaining budget; skip the cycle when at capacity or when the count cannot be determined.
  • processNextRun now returns a result so the drain loop knows when to stop (no run, capacity reached, or failure).
  • Add run_controller_jobs_at_capacity_skips_total metric.
  • Introduce JobManager interface to unit-test the control flow; add tests for draining, capacity limits, and availableCapacity branches.

The run-controller previously created at most one job per polling
interval, so a backlog of runs drained at 1 run / interval. It also
had no concurrency limit: it would claim a run, fail job creation when
the namespace was full, and report the run as FAILED.

Process queued runs back-to-back each polling cycle until the backlog
is empty, and gate fetching on a best-effort capacity check so we only
claim runs we are fairly sure we can place:

- Add maxConcurrentJobs config (default 20; negative = unlimited).
- Count unfinished runner jobs (CountActiveJobs) and drain only up to
  the remaining budget; skip the cycle when at capacity or when the
  count cannot be determined.
- processNextRun now returns a result so the drain loop knows when to
  stop (no run, capacity reached, or failure).
- Add run_controller_jobs_at_capacity_skips_total metric.
- Introduce JobManager interface to unit-test the control flow; add
  tests for draining, capacity limits, and availableCapacity branches.
@tfelix tfelix requested a review from grubmeshi June 23, 2026 12:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant