Files
coder/enterprise/coderd/prebuilds
5563b7444d fix: keep in-flight builds from blocking the prebuild hard limit (#30060)
Fixes #30058.

Fixes an issue where in-flight prebuilds prevent presets from reaching their failure hard limit. `GetPresetsAtFailureLimit` now considers only completed builds (`succeeded`, `failed`, `canceled`) when evaluating consecutive failures. Pending and running builds no longer mask earlier failures, while successful and canceled builds still break the failure streak.

### Tests
- Added query tests covering in-flight builds with and without a reached failure limit.
- Added a reconciler test confirming hard-limited presets do not create additional prebuilds.
- Fixed the test helper to properly mark successful jobs as completed.
- Verified the new tests fail before the fix and pass afterward.
- All relevant tests and `golangci-lint` pass.

**Live validation:** A preset with builds failing after 90s (longer than the 60s reconcile interval) stopped after 4 failures, with no additional builds during a 20-minute observation. Previously, the same scenario produced 156 failed builds in approximately 2 hours.

### AI disclosure
Written with AI assistance (Claude Code). I reviewed the changes, ran the tests, and verified the fix on a live deployment.

Co-authored-by: Bryson Henneberger <591079+PushTheLimit@users.noreply.github.com>
Co-authored-by: Bobby Ho <bobby@coder.com>
2026-11-09 18:02:55 +00:00
..