Skip to content

Commit 4a5bd75

Browse files
committed
fix update job status to db
1 parent fd08159 commit 4a5bd75

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

models/actions/task.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -263,15 +263,15 @@ func CreateTaskForRunner(ctx context.Context, runner *ActionRunner) (*ActionTask
263263
for page := 0; job == nil; page++ {
264264
var jobs []*ActionRunJob
265265
// Load only 10 job in a batch without all fields for memory / db load reduction
266-
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 {
266+
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 {
267267
return nil, false, err
268268
}
269269

270270
for _, v := range jobs {
271271
if runner.CanMatchLabels(v.RunsOn) {
272272
// Reserve our job before preparing task, otherwise continue searching
273273
v.TaskID = task.ID
274-
if n, err := UpdateRunJob(ctx, v, builder.Eq{"task_id": 0}); err != nil {
274+
if n, err := UpdateRunJob(ctx, v, builder.Eq{"task_id": 0}, "task_id"); err != nil {
275275
return nil, false, err
276276
} else if n == 1 {
277277
var exist bool
@@ -327,6 +327,10 @@ func CreateTaskForRunner(ctx context.Context, runner *ActionRunner) (*ActionTask
327327
return nil, false, err
328328
}
329329

330+
if _, err := UpdateRunJob(ctx, job, builder.Eq{"id": job.ID}, "attempt", "started", "status"); err != nil {
331+
return nil, false, err
332+
}
333+
330334
if len(workflowJob.Steps) > 0 {
331335
steps := make([]*ActionTaskStep, len(workflowJob.Steps))
332336
for i, v := range workflowJob.Steps {

0 commit comments

Comments
 (0)