Skip to content

Commit 0b17e10

Browse files
committed
migrate change
1 parent abee827 commit 0b17e10

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

services/actions/task.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,18 @@ func PickTask(ctx context.Context, runner *actions_model.ActionRunner) (*runnerv
2222
)
2323

2424
if err := db.WithTx(ctx, func(ctx context.Context) error {
25+
if runner.Ephemeral {
26+
var task actions_model.ActionTask
27+
has, err := db.GetEngine(ctx).Where("runner_id = ?", runner.ID).Get(&task)
28+
if err == nil && has {
29+
if task.Status == actions_model.StatusWaiting || task.Status == actions_model.StatusRunning || task.Status == actions_model.StatusBlocked {
30+
return nil
31+
}
32+
// task has been finished, remove it
33+
_, _ = db.GetEngine(ctx).Delete(runner)
34+
return fmt.Errorf("runner has been removed")
35+
}
36+
}
2537
t, ok, err := actions_model.CreateTaskForRunner(ctx, runner)
2638
if err != nil {
2739
return fmt.Errorf("CreateTaskForRunner: %w", err)

0 commit comments

Comments
 (0)