fix(actions): don't pick up jobs of repos with Actions disabled (#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`.
This commit is contained in:
silverwind
2026-10-31 15:28:58 +01:00
committed by GitHub
parent 8465bed994
commit cc20c4c11b
7 changed files with 48 additions and 55 deletions

View File

@@ -94,11 +94,12 @@ 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)
notifyAndEmitFinishedJobs(context.WithoutCancel(ctx), cancelledJobs) // the cancellations are committed even if the runner went away
if err != nil {
return nil, false, fmt.Errorf("CreateTaskForRunner: %w", err)
}
if !ok {
if t == nil {
return nil, false, nil
}

View File

@@ -61,9 +61,9 @@ func TestReleaseTaskForRunnerCleanup(t *testing.T) {
runner.GenerateAndFillToken()
require.NoError(t, db.Insert(t.Context(), runner))
task, ok, err := actions_model.CreateTaskForRunner(t.Context(), runner)
task, _, err := actions_model.CreateTaskForRunner(t.Context(), runner)
require.NoError(t, err)
require.True(t, ok)
require.NotNil(t, task)
require.Equal(t, actions_model.StatusRunning, unittest.AssertExistsAndLoadBean(t, &actions_model.ActionRunJob{ID: job.ID}).Status)
// the cleanup helper uses its own context, so the claimed job is returned to the waiting queue