diff --git a/models/actions/runner.go b/models/actions/runner.go index 84398b143b..738e74c9f8 100644 --- a/models/actions/runner.go +++ b/models/actions/runner.go @@ -263,7 +263,7 @@ func (opts FindRunnerOptions) ToOrders() string { // GetRunnerByUUID returns a runner via uuid func GetRunnerByUUID(ctx context.Context, uuid string) (*ActionRunner, error) { var runner ActionRunner - has, err := db.GetEngine(ctx).Where("uuid=?", uuid).Get(&runner) + has, err := db.GetEngine(ctx).Where("uuid=?", uuid).Unscoped().Get(&runner) if err != nil { return nil, err } else if !has { diff --git a/routers/api/actions/runner/interceptor.go b/routers/api/actions/runner/interceptor.go index 521ba910e3..b87ee9c269 100644 --- a/routers/api/actions/runner/interceptor.go +++ b/routers/api/actions/runner/interceptor.go @@ -46,11 +46,19 @@ var withRunner = connect.WithInterceptors(connect.UnaryInterceptorFunc(func(unar } cols := []string{"last_online"} - runner.LastOnline = timeutil.TimeStampNow() + if methodName == "UpdateTask" || methodName == "UpdateLog" { + if runner.Deleted > 0 && timeutil.TimeStampNow()-runner.Deleted > timeutil.TimeStamp(10) { + return nil, status.Error(codes.Internal, "Runner is deleted") + } runner.LastActive = timeutil.TimeStampNow() cols = append(cols, "last_active") + } else if runner.Deleted != 0 { + return nil, status.Error(codes.Internal, "Runner is deleted") } + + runner.LastOnline = timeutil.TimeStampNow() + if err := actions_model.UpdateRunner(ctx, runner, cols...); err != nil { log.Error("can't update runner status: %v", err) } diff --git a/routers/api/actions/runner/runner.go b/routers/api/actions/runner/runner.go index 86bab4b340..f1eccb1c58 100644 --- a/routers/api/actions/runner/runner.go +++ b/routers/api/actions/runner/runner.go @@ -289,7 +289,7 @@ func (s *Service) UpdateLog( } } - if err := actions_model.UpdateTask(ctx, task, "log_indexes", "log_length", "log_size", "log_in_storage"); err != nil { + if err := actions_model.UpdateTask(ctx, task, "status", "log_indexes", "log_length", "log_size", "log_in_storage"); err != nil { return nil, status.Errorf(codes.Internal, "update task: %v", err) } if remove != nil {