0
0
mirror of https://github.com/go-gitea/gitea.git synced 2026-04-25 15:36:18 +02:00

fixes: ephemeral runner UpdateLogs getting rejected when the runner has been deleted

This commit is contained in:
rmawatson 2026-02-15 16:38:24 +00:00
parent b8e5e2a93e
commit 1b4a0a769b
3 changed files with 14 additions and 3 deletions

View File

@ -255,7 +255,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 {

View File

@ -41,16 +41,27 @@ var withRunner = connect.WithInterceptors(connect.UnaryInterceptorFunc(func(unar
}
return nil, status.Error(codes.Internal, err.Error())
}
if subtle.ConstantTimeCompare([]byte(runner.TokenHash), []byte(auth_model.HashToken(token, runner.TokenSalt))) != 1 {
return nil, status.Error(codes.Unauthenticated, "unregistered runner")
}
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)
}

View File

@ -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 {