fix update job status to db

pull/35960/head
Christopher Homberger 2025-11-14 18:31:15 +01:00
parent fd08159c18
commit 4a5bd7508c
1 changed files with 6 additions and 2 deletions

View File

@ -263,7 +263,7 @@ func CreateTaskForRunner(ctx context.Context, runner *ActionRunner) (*ActionTask
for page := 0; job == nil; page++ {
var jobs []*ActionRunJob
// Load only 10 job in a batch without all fields for memory / db load reduction
if err := e.Where("task_id=? AND status=? AND updated>?", 0, StatusWaiting, lastUpdated).Cols("id", "runs_on").And(jobCond).Asc("updated", "id").Limit(limit).Find(&jobs); err != nil {
if err := e.Where("task_id=? AND status=? AND updated>?", 0, StatusWaiting, lastUpdated).Cols("id", "runs_on", "updated").And(jobCond).Asc("updated", "id").Limit(limit).Find(&jobs); err != nil {
return nil, false, err
}
@ -271,7 +271,7 @@ func CreateTaskForRunner(ctx context.Context, runner *ActionRunner) (*ActionTask
if runner.CanMatchLabels(v.RunsOn) {
// Reserve our job before preparing task, otherwise continue searching
v.TaskID = task.ID
if n, err := UpdateRunJob(ctx, v, builder.Eq{"task_id": 0}); err != nil {
if n, err := UpdateRunJob(ctx, v, builder.Eq{"task_id": 0}, "task_id"); err != nil {
return nil, false, err
} else if n == 1 {
var exist bool
@ -327,6 +327,10 @@ func CreateTaskForRunner(ctx context.Context, runner *ActionRunner) (*ActionTask
return nil, false, err
}
if _, err := UpdateRunJob(ctx, job, builder.Eq{"id": job.ID}, "attempt", "started", "status"); err != nil {
return nil, false, err
}
if len(workflowJob.Steps) > 0 {
steps := make([]*ActionTaskStep, len(workflowJob.Steps))
for i, v := range workflowJob.Steps {