Skip to content

Commit bab5ff2

Browse files
committed
update
1 parent f19e9e3 commit bab5ff2

File tree

1 file changed

+16
-10
lines changed

1 file changed

+16
-10
lines changed

services/actions/clear_tasks.go

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ func CancelAbandonedJobs(ctx context.Context) error {
106106
UpdatedBefore: timeutil.TimeStamp(time.Now().Add(-setting.Actions.AbandonedJobTimeout).Unix()),
107107
})
108108
if err != nil {
109-
log.Warn("find abandoned tasks: %v", err)
109+
log.Error("CancelAbandonedJobs: %v", err)
110110
return err
111111
}
112112

@@ -124,7 +124,7 @@ func CancelAbandonedJobs(ctx context.Context) error {
124124
updated = err == nil && n > 0
125125
return err
126126
}); err != nil {
127-
log.Warn("cancel abandoned job %v: %v", job.ID, err)
127+
log.Warn("CancelAbandonedJobs jobid %v: %v", job.ID, err)
128128
// go on
129129
}
130130
CreateCommitStatus(ctx, job)
@@ -134,18 +134,24 @@ func CancelAbandonedJobs(ctx context.Context) error {
134134
}
135135
}
136136

137-
for _, job := range updatedRuns {
138-
c, err := db.Count[actions_model.ActionRunJob](ctx, actions_model.FindRunJobOptions{
139-
RunID: job.RunID,
140-
Statuses: []actions_model.Status{actions_model.StatusWaiting, actions_model.StatusBlocked, actions_model.StatusRunning},
141-
})
137+
for _, obj := range updatedRuns {
138+
jobs, err := actions_model.GetRunJobsByRunID(ctx, obj.RunID)
142139
if err != nil {
143-
log.Error("Count waiting jobs for run %d: %v", job.RunID, err)
140+
log.Error("CancelAbandonedJobs runid %d: %v", obj.RunID, err)
144141
continue
145142
}
146-
if c == 0 {
147-
NotifyWorkflowRunStatusUpdateWithReload(ctx, job)
143+
144+
unfinished := false
145+
for _, job := range jobs {
146+
if !job.Status.IsDone() {
147+
unfinished = true
148+
break
149+
}
150+
}
151+
if unfinished {
152+
continue
148153
}
154+
NotifyWorkflowRunStatusUpdateWithReload(ctx, obj)
149155
}
150156

151157
return nil

0 commit comments

Comments
 (0)