Skip to content

fix(runners): Drop requests for jobs GitHub has already assigned or finished - #261

Open
nfebe wants to merge 1 commit into
feat/runner-performancefrom
fix/github-runner-cancellation
Open

nfebe wants to merge 1 commit into
feat/runner-performancefrom
fix/github-runner-cancellation

Conversation

@nfebe

@nfebe nfebe commented Nov 20, 2026

Copy link
Copy Markdown
Contributor

FlatRun clears pending runner requests when GitHub assigns or finishes a job. Before starting a runner, it checks whether the job is still queued so a missed webhook cannot waste a worker. Private repositories need Actions read permission for that check.

…inished

Release queued capacity when GitHub assigns or finishes a job. Check
that the job still needs a runner before provisioning one so a missed
delivery cannot leave a stale request consuming a worker.
@sourceant

sourceant Bot commented Nov 20, 2026

Copy link
Copy Markdown

Code Review Summary

FlatRun now cancels pending runner requests when GitHub assigns or completes their workflow job, and checks that a job is still queued before creating its JIT configuration. This also catches missed or out-of-order webhook deliveries; failed status lookups fail the local run. Private repositories need Actions read permission for the check.

🚀 Key Improvements

  • Avoids starting runners for jobs already assigned or finished.

📉 Regressions

  • Private-repository runner setup without Actions read permission now fails during job preparation.

💡 Minor Suggestions

  • Clearing the key when JIT preparation returns makes this run invisible to cancellation while the worker is still setting up the runtime. If an in_progress or completed webhook arrives in that gap, the stale runner request can still start and consume a worker; keep it cancellable until startup or perform a final status check immediately before launch.
  • Review coverage is incomplete. Inspect the execution details before approving.

@sourceant sourceant Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review complete. See the overview comment for a summary.

Comment thread internal/runs/manager.go
if prepare := queued.preparation.Apply; prepare != nil {
needed, err := prepare(ctx, queued.secrets)
m.mu.Lock()
queued.preparation.Key = ""

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Clearing the key when JIT preparation returns makes this run invisible to cancellation while the worker is still setting up the runtime. If an in_progress or completed webhook arrives in that gap, the stale runner request can still start and consume a worker; keep it cancellable until startup or perform a final status check immediately before launch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant