feat: Add label support to TotalNumberOfQueuedAndInProgressWorkflowRuns metric (#1373)

This is an implementation for my intepretation of the "bronze" case proposed in #1056

Ref #1056
This commit is contained in:
Yusuke Kuoka
2022-04-24 14:41:34 +09:00
committed by GitHub
parent e8ef84ab76
commit a622968ff2
3 changed files with 232 additions and 10 deletions

View File

@@ -138,7 +138,23 @@ func (r *HorizontalRunnerAutoscalerReconciler) suggestReplicasByQueuedAndInProgr
if len(allJobs) == 0 {
fallback_cb()
} else {
JOB:
for _, job := range allJobs {
labels := make(map[string]struct{}, len(job.Labels))
for _, l := range job.Labels {
labels[l] = struct{}{}
}
if _, ok := labels["self-hosted"]; !ok {
continue JOB
}
for _, l := range st.labels {
if _, ok := labels[l]; !ok {
continue JOB
}
}
switch job.GetStatus() {
case "completed":
// We add a case for `completed` so it is not counted in `unknown`.