You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Controller misses a queued job that GitHub's status=queued run list leaves out #55
On 2026-11-21, fourbite/qube-server CI run 44936666005 (a push to main at 18:38:52Z) sat queued for 25 minutes with no runner.
The controller logged the workflow_jobqueued webhooks at 18:38:55. Every cycle after that reported created 0, failed false, including the first cycle after a controller restart (so it wasn't the ETag cache).
GitHub's filtered list GET /repos/fourbite/qube-server/actions/runs?status=queued did not include the run. It returned only 43098043801, an old run from 2026-11-11. The unfiltered GET /actions/runs showed 44936666005 as queued, and so did its jobs (labels self-hosted, linux, x64, railway-private).
QueuedJobs → repoJobs find demand only through runs?status=queued|pending|in_progress, so a run that GitHub's status filter misses is never seen.
Cancelling and re-running the run put it in the filtered list, and a runner took it at once.
Fix
Don't depend only on the filtered runs list for demand:
Remember the job ids from workflow_jobqueued webhooks. Each cycle, read each still-unseen job directly (GET /repos/{repo}/actions/jobs/{id}) until it is no longer queued, or for at most MAX_JOB_MINUTES.
Or, when the filtered list is empty, also read the first page of the unfiltered runs list (per_page=20) and keep the queued ones. This only costs a call when nothing else is queued.
Acceptance
A job announced by a queued webhook but missing from runs?status=queued gets a runner within one cycle. Covered by a test with a fake GitHub that leaves the run out of the filtered list.
A webhook job that never shows up (its run was cancelled) is dropped once it reads as completed, and it never creates a runner.
/healthz or the cycle log counts jobs found only through this fallback, so the GitHub-side gap stays visible.
Note: 43098043801 still sits in the filtered queued list with nothing to run. It's harmless today, but the fallback must not create runners for a run whose jobs aren't queued.
Approach: the unfiltered-list fallback, not webhook memory. It keeps the controller stateless (GitHub is read afresh each cycle, and webhooks stay a "when" signal only), works when webhooks are not set up or a delivery is lost, and adds no new state to lose on restart.
One change to the fallback's trigger compared with the issue text: "when the filtered list is empty" would not have caught the incident, because the filtered queued list was not empty (it held the stale run 43098043801). So the trigger is "the filtered lists found no queued job of ours in this repository".
In ghapp.repoJobs, per repository:
Read runs?status=queued|pending|in_progress as today and collect their queued jobs.
If that found no job for our label, read one page of GET /repos/{repo}/actions/runs?per_page=20 (no status filter). For each run that is not completed and was not already in a filtered list, read its jobs with the same runJobs (only queued jobs whose labels we can serve), and mark those jobs Unlisted.
The extra GET goes through the existing ETag cache (the answer carries total_count), so on an idle repository it is a 304 and does not count against the rate limit.
In the controller: count the unlisted jobs per cycle, add unlisted to the cycle log line, log one warning per unlisted job (repo and job id, the log is private), and expose on /healthzunlisted_jobs (last cycle) and unlisted_jobs_total (distinct jobs since start). Both are counts only, since /healthz is public.
Invariants not to break
No runner for a run whose jobs are not queued (the stale 43098043801 case): jobs still pass the status == "queued" and label checks in runJobs.
A job is never counted twice (the shared seen set still applies).
A 404 on a run that vanished between list and jobs read is still skipped; other errors still fail the read of the scope.
No new state is lost on restart that matters: only the distinct counter for /healthz.
Tests, one per acceptance criterion
A fake GitHub lists the run in the unfiltered list but not in status=queued: QueuedJobs returns its job marked unlisted, and a controller cycle creates a runner for it.
A run in the unfiltered list that was cancelled (its jobs read completed) gives no job and no runner.
The cycle log and /healthz count unlisted jobs (unlisted_jobs, unlisted_jobs_total not double-counting a job seen in two cycles).
A stale run in the filtered queued list whose jobs are not queued gives no runner, and the fallback still runs and finds the missed run.
When the filtered lists already found a job, no unfiltered request is made.
Known limit: a missed run older than the 20 newest runs, or a missed run in a repo where another queued job was found, is only caught on a later cycle (the second case once that job is taken). I will say so in the PR and the README.
The unfiltered page is read for every repository, every cycle, not only when the filtered lists found nothing. Otherwise a missed run in a repository that has another queued job waits for later cycles, which breaks "a runner within one cycle". It is one GET (runs?per_page=20, read once with no paging), and runs already in a filtered list are skipped.
unlisted_jobs_total is dropped. The controller keeps no new state between cycles. /healthz gets unlisted_jobs (the last cycle), the cycle line gets unlisted=N, and each unlisted job gets a warning naming its repo and id.
Known limit, said plainly: the fallback never finds a missed run once 20 newer runs push it off the first page. Cancel and re-run that run. A time filter in the URL would change it every cycle and defeat the ETag cache, so I'm not adding one.
Cost: on an idle repository the page does not change, so the read is a 304 and does not count against the rate limit. A repository with recent activity pays one full call per cycle. The conditional-request cache (2000 entries) now holds four list URLs per repository, so it fills at about 500 repositories instead of about 660. This goes in docs/deploy.md.
A run in a status the filtered lists never ask for (waiting, requested, action_required) is read through the fallback too. Its jobs count as unlisted only if they are queued and ours.
How each acceptance criterion maps onto the fallback:
A job left out of runs?status=queued is found through the unfiltered page in the same cycle. There's a ghapp test with a fake GitHub that leaves the run out, and a controller test showing the job gets a runner.
"A webhook job that never shows up is dropped": the fallback keeps no webhook memory, so there is nothing to drop. A cancelled run (completed) is not read at all. A run that is not completed but whose jobs are not queued gives no job. Both have tests.
/healthzunlisted_jobs and the cycle line unlisted=N, tested.
The stale run in the filtered queued list gives no runner, and its jobs are read only once (asserted by counting requests).
Tests also cover: a run that vanishes between the list and the jobs read is skipped, and any other error on the fallback fails the read. The existing ETag test changes from four 304s to five. README.md, docs/deploy.md and CHANGELOG.md are updated.
Started. The failing tests are on branch fix/55-unlisted-queued-job in draft PR #56, and the plan above was revised after review. Next: the fallback read of the unfiltered run list, the healthz and log counts, and the docs.
PR #56 is ready for review. Each cycle now also reads the 20 newest runs of each repository without the status filter and serves the queued jobs of runs the filtered lists left out. /healthz reports unlisted_jobs, and the cycle log line carries unlisted. The tests and the quality gate pass locally and in CI (all five gate checks; mutation 15 killed, 0 survived). It waits on review, merge and deploy. Not verified against real GitHub: the gap can't be reproduced on demand, so after the deploy watch the warn lines and unlisted_jobs.
Notes: when GitHub's status filter misses a run it can also keep listing a stale one, so a fallback that runs only when the filtered list is empty would have missed this incident.
Fixed in #56 (squash f00cdb7) and rolled out. controller, controller-pg and controller-php all run ghcr.io/farzai/github-runner-railway-controller:f00cdb77666cfdc59f1c050c72d2b366c2b3de2f (SUCCESS). The first cycles on the new image: failed false, unlisted 0, unlisted_read_failed 0. Rollback image: 08061db.
Activity
parsilver commentedon Nov 21, 2026
Work started.
parsilver commentedon Nov 21, 2026
Plan
Approach: the unfiltered-list fallback, not webhook memory. It keeps the controller stateless (GitHub is read afresh each cycle, and webhooks stay a "when" signal only), works when webhooks are not set up or a delivery is lost, and adds no new state to lose on restart.
One change to the fallback's trigger compared with the issue text: "when the filtered list is empty" would not have caught the incident, because the filtered
queuedlist was not empty (it held the stale run 43098043801). So the trigger is "the filtered lists found no queued job of ours in this repository".In
ghapp.repoJobs, per repository:runs?status=queued|pending|in_progressas today and collect their queued jobs.GET /repos/{repo}/actions/runs?per_page=20(no status filter). For each run that is notcompletedand was not already in a filtered list, read its jobs with the samerunJobs(onlyqueuedjobs whose labels we can serve), and mark those jobsUnlisted.total_count), so on an idle repository it is a 304 and does not count against the rate limit.In the controller: count the unlisted jobs per cycle, add
unlistedto the cycle log line, log one warning per unlisted job (repo and job id, the log is private), and expose on/healthzunlisted_jobs(last cycle) andunlisted_jobs_total(distinct jobs since start). Both are counts only, since/healthzis public.Invariants not to break
status == "queued"and label checks inrunJobs.seenset still applies)./healthz.Tests, one per acceptance criterion
status=queued:QueuedJobsreturns its job marked unlisted, and a controller cycle creates a runner for it.completed) gives no job and no runner./healthzcount unlisted jobs (unlisted_jobs,unlisted_jobs_totalnot double-counting a job seen in two cycles).queuedlist whose jobs are not queued gives no runner, and the fallback still runs and finds the missed run.Known limit: a missed run older than the 20 newest runs, or a missed run in a repo where another queued job was found, is only caught on a later cycle (the second case once that job is taken). I will say so in the PR and the README.
parsilver commentedon Nov 21, 2026
Plan, revised after a fresh review
Changes from the plan above:
runs?per_page=20, read once with no paging), and runs already in a filtered list are skipped.unlisted_jobs_totalis dropped. The controller keeps no new state between cycles./healthzgetsunlisted_jobs(the last cycle), the cycle line getsunlisted=N, and each unlisted job gets a warning naming its repo and id.waiting,requested,action_required) is read through the fallback too. Its jobs count as unlisted only if they arequeuedand ours.How each acceptance criterion maps onto the fallback:
runs?status=queuedis found through the unfiltered page in the same cycle. There's a ghapp test with a fake GitHub that leaves the run out, and a controller test showing the job gets a runner.completed) is not read at all. A run that is not completed but whose jobs are not queued gives no job. Both have tests./healthzunlisted_jobsand the cycle lineunlisted=N, tested.queuedlist gives no runner, and its jobs are read only once (asserted by counting requests).Tests also cover: a run that vanishes between the list and the jobs read is skipped, and any other error on the fallback fails the read. The existing ETag test changes from four 304s to five. README.md, docs/deploy.md and CHANGELOG.md are updated.
parsilver commentedon Nov 21, 2026
Started. The failing tests are on branch
fix/55-unlisted-queued-jobin draft PR #56, and the plan above was revised after review. Next: the fallback read of the unfiltered run list, the healthz and log counts, and the docs.parsilver commentedon Nov 21, 2026
PR #56 is ready for review. Each cycle now also reads the 20 newest runs of each repository without the status filter and serves the queued jobs of runs the filtered lists left out.
/healthzreportsunlisted_jobs, and the cycle log line carriesunlisted. The tests and the quality gate pass locally and in CI (all five gate checks; mutation 15 killed, 0 survived). It waits on review, merge and deploy. Not verified against real GitHub: the gap can't be reproduced on demand, so after the deploy watch the warn lines andunlisted_jobs.Notes: when GitHub's status filter misses a run it can also keep listing a stale one, so a fallback that runs only when the filtered list is empty would have missed this incident.
parsilver commentedon Nov 21, 2026
Fixed in #56 (squash f00cdb7) and rolled out. controller, controller-pg and controller-php all run
ghcr.io/farzai/github-runner-railway-controller:f00cdb77666cfdc59f1c050c72d2b366c2b3de2f(SUCCESS). The first cycles on the new image:failed false,unlisted 0,unlisted_read_failed 0. Rollback image: 08061db.