@@ -43,6 +43,7 @@ func stopTasks(ctx context.Context, opts actions_model.FindTaskOptions) error {
43
43
return fmt .Errorf ("find tasks: %w" , err )
44
44
}
45
45
46
+ jobs := make ([]* actions_model.ActionRunJob , 0 , len (tasks ))
46
47
for _ , task := range tasks {
47
48
if err := db .WithTx (ctx , func (ctx context.Context ) error {
48
49
if err := actions_model .StopTask (ctx , task .ID , actions_model .StatusFailure ); err != nil {
@@ -51,7 +52,8 @@ func stopTasks(ctx context.Context, opts actions_model.FindTaskOptions) error {
51
52
if err := task .LoadJob (ctx ); err != nil {
52
53
return err
53
54
}
54
- return CreateCommitStatus (ctx , task .Job )
55
+ jobs = append (jobs , task .Job )
56
+ return nil
55
57
}); err != nil {
56
58
log .Warn ("Cannot stop task %v: %v" , task .ID , err )
57
59
// go on
@@ -61,6 +63,14 @@ func stopTasks(ctx context.Context, opts actions_model.FindTaskOptions) error {
61
63
remove ()
62
64
}
63
65
}
66
+
67
+ for _ , job := range jobs {
68
+ if err := CreateCommitStatus (ctx , job ); err != nil {
69
+ log .Error ("Update commit status for job %v failed: %v" , job .ID , err )
70
+ // go on
71
+ }
72
+ }
73
+
64
74
return nil
65
75
}
66
76
@@ -80,14 +90,16 @@ func CancelAbandonedJobs(ctx context.Context) error {
80
90
job .Status = actions_model .StatusCancelled
81
91
job .Stopped = now
82
92
if err := db .WithTx (ctx , func (ctx context.Context ) error {
83
- if _ , err := actions_model .UpdateRunJob (ctx , job , nil , "status" , "stopped" ); err != nil {
84
- return err
85
- }
86
- return CreateCommitStatus (ctx , job )
93
+ _ , err := actions_model .UpdateRunJob (ctx , job , nil , "status" , "stopped" )
94
+ return err
87
95
}); err != nil {
88
96
log .Warn ("cancel abandoned job %v: %v" , job .ID , err )
89
97
// go on
90
98
}
99
+ if err := CreateCommitStatus (ctx , job ); err != nil {
100
+ log .Error ("Update commit status for job %v failed: %v" , job .ID , err )
101
+ // go on
102
+ }
91
103
}
92
104
93
105
return nil
0 commit comments