-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(allocator): job capacity exceeded on runners (#723)
Fixes a bug which allowed a runner's job capacity to be exceeded. The allocator is responsible for allocated jobs to a runner. It should respect the runner's capacity, i.e. the max number of jobs it is permitted to run at once. It keeps a tally of the number of jobs allocated to each runner. However, the allocator would also subscribe to runner events and whenever an event arrived, it would overwrite its local tally with the tally embedded in the event. That's problematic because an event is something that happened in the past, and it can be stale, containing a lower tally than that maintained locally. The allocator would then wrongly allocate another job to the runner. This fix instead maintains a local tally for each runner in the allocator and ignores the tallies in events.
- Loading branch information
Showing
3 changed files
with
100 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package runner | ||
|
||
import "github.com/prometheus/client_golang/prometheus" | ||
|
||
func init() { | ||
prometheus.MustRegister(currentJobsMetric) | ||
} | ||
|
||
const runnerIDLabel = "runner_id" | ||
|
||
var currentJobsMetric = prometheus.NewGaugeVec(prometheus.GaugeOpts{ | ||
Namespace: "otf", | ||
Subsystem: "allocator", | ||
Name: "current_jobs", | ||
Help: "Current jobs by runner ID", | ||
}, []string{runnerIDLabel}) |