From 1b4a0a769b57fd8217326e888fba3d13315953cf Mon Sep 17 00:00:00 2001 From: rmawatson Date: Sun, 15 Feb 2026 16:38:24 +0000 Subject: [PATCH 1/3] fixes: ephemeral runner UpdateLogs getting rejected when the runner has been deleted --- models/actions/runner.go | 2 +- routers/api/actions/runner/interceptor.go | 13 ++++++++++++- routers/api/actions/runner/runner.go | 2 +- 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/models/actions/runner.go b/models/actions/runner.go index 81d4249ae0..f313f9465e 100644 --- a/models/actions/runner.go +++ b/models/actions/runner.go @@ -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 { diff --git a/routers/api/actions/runner/interceptor.go b/routers/api/actions/runner/interceptor.go index 521ba910e3..d297f73d43 100644 --- a/routers/api/actions/runner/interceptor.go +++ b/routers/api/actions/runner/interceptor.go @@ -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) } diff --git a/routers/api/actions/runner/runner.go b/routers/api/actions/runner/runner.go index 55ba7862a9..b55e02522d 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 { From fc5662947c02757468099821c9e64057b9d58dda Mon Sep 17 00:00:00 2001 From: rmawatson Date: Sun, 15 Feb 2026 17:17:21 +0000 Subject: [PATCH 2/3] removed ws --- routers/api/actions/runner/interceptor.go | 1 - 1 file changed, 1 deletion(-) diff --git a/routers/api/actions/runner/interceptor.go b/routers/api/actions/runner/interceptor.go index d297f73d43..7382014258 100644 --- a/routers/api/actions/runner/interceptor.go +++ b/routers/api/actions/runner/interceptor.go @@ -41,7 +41,6 @@ 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") } From 72e49f3d4249a651c0bd9320f5ae6182f03e2c34 Mon Sep 17 00:00:00 2001 From: rmawatson Date: Sun, 15 Feb 2026 17:18:45 +0000 Subject: [PATCH 3/3] removed ws --- routers/api/actions/runner/interceptor.go | 2 -- 1 file changed, 2 deletions(-) diff --git a/routers/api/actions/runner/interceptor.go b/routers/api/actions/runner/interceptor.go index 7382014258..b87ee9c269 100644 --- a/routers/api/actions/runner/interceptor.go +++ b/routers/api/actions/runner/interceptor.go @@ -51,10 +51,8 @@ var withRunner = connect.WithInterceptors(connect.UnaryInterceptorFunc(func(unar 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") }