File tree Expand file tree Collapse file tree 1 file changed +12
-0
lines changed Expand file tree Collapse file tree 1 file changed +12
-0
lines changed Original file line number Diff line number Diff 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 )
You can’t perform that action at this time.
0 commit comments