Skip to content

Commit a0709c2

Browse files
committed
feat: filter GitHub workflows via query parameter for better queue count accuracy
Signed-off-by: silviu-dinu <[email protected]>
1 parent d76aa17 commit a0709c2

File tree

3 files changed

+20
-6
lines changed

3 files changed

+20
-6
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ Here is an overview of all new **experimental** features:
7171

7272
### Improvements
7373

74+
- **GitHub Scaler**: Filter workflows via query parameter for improved queue count accuracy ([#6519](https://github.com/kedacore/keda/pull/6519))
7475
- **IBMMQ Scaler**: Handling StatusNotFound in IBMMQ scaler ([#6472](https://github.com/kedacore/keda/pull/6472))
7576

7677
### Fixes

pkg/scalers/github_runner_scaler.go

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -618,8 +618,8 @@ func (s *githubRunnerScaler) getWorkflowRunJobs(ctx context.Context, workflowRun
618618
}
619619

620620
// getWorkflowRuns returns a list of workflow runs for a given repository
621-
func (s *githubRunnerScaler) getWorkflowRuns(ctx context.Context, repoName string) (*WorkflowRuns, error) {
622-
url := fmt.Sprintf("%s/repos/%s/%s/actions/runs", s.metadata.githubAPIURL, s.metadata.owner, repoName)
621+
func (s *githubRunnerScaler) getWorkflowRuns(ctx context.Context, repoName string, status string) (*WorkflowRuns, error) {
622+
url := fmt.Sprintf("%s/repos/%s/%s/actions/runs?status=%s", s.metadata.githubAPIURL, s.metadata.owner, repoName, status)
623623
body, statusCode, err := getGithubRequest(ctx, url, s.metadata, s.httpClient)
624624
if err != nil && statusCode == 404 {
625625
return nil, nil
@@ -672,12 +672,19 @@ func (s *githubRunnerScaler) GetWorkflowQueueLength(ctx context.Context) (int64,
672672
var allWfrs []WorkflowRuns
673673

674674
for _, repo := range repos {
675-
wfrs, err := s.getWorkflowRuns(ctx, repo)
675+
wfrsQueued, err := s.getWorkflowRuns(ctx, repo, "queued")
676676
if err != nil {
677677
return -1, err
678678
}
679-
if wfrs != nil {
680-
allWfrs = append(allWfrs, *wfrs)
679+
if wfrsQueued != nil {
680+
allWfrs = append(allWfrs, *wfrsQueued)
681+
}
682+
wfrsInProgress, err := s.getWorkflowRuns(ctx, repo, "in_progress")
683+
if err != nil {
684+
return -1, err
685+
}
686+
if wfrsInProgress != nil {
687+
allWfrs = append(allWfrs, *wfrsInProgress)
681688
}
682689
}
683690

0 commit comments

Comments
 (0)