fix(actions): don't pick up jobs of repos with Actions disabled (#40106) (#40122)

Backport https://github.com/go-gitea/gitea/pull/40106

Repository-level and instance-level runners still picked up waiting jobs
of repositories with Actions disabled.
https://github.com/go-gitea/gitea/pull/30331 only covered owner-level
runners, by filtering them out in SQL.

Pickup now checks the Actions unit of each job it is about to claim, for
every runner scope, and cancels the job instead when Actions is
disabled, also honoring `DISABLED_REPO_UNITS`. Disabling Actions
therefore cancels its queued jobs once a matching runner polls, instead
of leaving them waiting until `ABANDONED_JOB_TIMEOUT`.

Co-authored-by: silverwind <me@silverwind.io>
This commit is contained in:
bircniandsilverwind authored and GitHub committed 2026-10-31 15:56:26 +00:00
1 parent c9e1805cc9
commit 6c8eaaf9e7
7 files changed
+58 -56

No files matched your search

+4 -2
View File
@@ -94,11 +94,13 @@ func PickTask(ctx context.Context, runner *actions_model.ActionRunner) (*runnerv
}
}
t, ok, err := actions_model.CreateTaskForRunner(ctx, runner)
t, cancelledJobs, err := actions_model.CreateTaskForRunner(ctx, runner)
NotifyWorkflowJobsAndRunsStatusUpdate(context.WithoutCancel(ctx), cancelledJobs) // the cancellations are committed even if the runner went away
EmitJobsIfReadyByJobs(cancelledJobs)
if err != nil {
return nil, false, fmt.Errorf("CreateTaskForRunner: %w", err)
}
if !ok {
if t == nil {
return nil, false, nil
}