WIP: Preserve legacy KEDA label-query filter #3

Draft
mfreeman451 wants to merge 1 commit from codex/preserve-label-query-filter into main
Owner

Tracks #2.\n\nDurability checkpoint for local commit 395a262 found during checkout cleanup. Merged PR #1 supersedes this implementation with runs_on and repository allowlist filtering. Do not merge as-is; compare for any missing tests or behavior and port only what is still useful.

Tracks #2.\n\nDurability checkpoint for local commit 395a262 found during checkout cleanup. Merged PR #1 supersedes this implementation with runs_on and repository allowlist filtering. Do not merge as-is; compare for any missing tests or behavior and port only what is still useful.
feat: filter /jobs metric by runner label via labels query param
All checks were successful
CI / test (pull_request) Successful in 1m4s
395a262a47
Add an optional `labels` query parameter to the /jobs endpoint so KEDA
ScaledObjects can target a specific runner label (e.g. the serviceradar
signing runner) instead of counting every queued/running job.

- job struct gains a Labels []string field (parsed from the Forgejo
  runner-jobs API `labels` field; see note below)
- handleJobs reads ?labels=a,b,c (comma-split, trimmed, lowercased,
  empties dropped) and threads it through fetchMetric -> countJobs
- countJobs now counts a job only when it passes the status filter AND
  (no labels requested OR the job carries at least one requested label,
  case-insensitive). Behavior is unchanged when no labels param is given.

NOTE: the Forgejo /api/v1/admin/runners/jobs job object's label field
name is assumed to be `labels`. If Forgejo names it differently the
signing metric reads 0 and the runner simply will not scale up, which
is a safe degradation rather than a breakage.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
All checks were successful
CI / test (pull_request) Successful in 1m4s
This pull request has changes conflicting with the target branch.
  • cmd/forgejo-keda-adapter/main.go
  • cmd/forgejo-keda-adapter/main_test.go
View command line instructions

Manual merge helper

Use this merge commit message when completing the merge manually.

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin codex/preserve-label-query-filter:codex/preserve-label-query-filter
git switch codex/preserve-label-query-filter

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch main
git merge --no-ff codex/preserve-label-query-filter
git switch codex/preserve-label-query-filter
git rebase main
git switch main
git merge --ff-only codex/preserve-label-query-filter
git switch codex/preserve-label-query-filter
git rebase main
git switch main
git merge --no-ff codex/preserve-label-query-filter
git switch main
git merge --squash codex/preserve-label-query-filter
git switch main
git merge --ff-only codex/preserve-label-query-filter
git switch main
git merge codex/preserve-label-query-filter
git push origin main
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
carverauto/forgejo-keda-adapter!3
No description provided.