From 9de33d425202f334a3e55fd7c53b0fcd67aa0479 Mon Sep 17 00:00:00 2001 From: GitCaddy Date: Sun, 11 Jan 2026 07:03:54 +0000 Subject: [PATCH] Send runner capabilities with FetchTask poll - Add envcheck import and capability detection to poller.go - Send capabilities JSON with every FetchTask request - Use GitCaddy actions-proto-go v0.5.6 with CapabilitiesJson field --- go.mod | 5 +++-- go.sum | 4 ++-- internal/app/poll/poller.go | 16 ++++++++++++---- 3 files changed, 17 insertions(+), 8 deletions(-) diff --git a/go.mod b/go.mod index f78df45..bcda02c 100644 --- a/go.mod +++ b/go.mod @@ -23,6 +23,8 @@ require ( gotest.tools/v3 v3.5.1 ) +require golang.org/x/sys v0.37.0 + require ( cyphar.com/go-pathrs v0.2.1 // indirect dario.cat/mergo v1.0.0 // indirect @@ -96,7 +98,6 @@ require ( golang.org/x/crypto v0.43.0 // indirect golang.org/x/net v0.45.0 // indirect golang.org/x/sync v0.16.0 // indirect - golang.org/x/sys v0.37.0 // indirect golang.org/x/tools v0.23.0 // indirect gopkg.in/warnings.v0 v0.1.2 // indirect gopkg.in/yaml.v2 v2.4.0 // indirect @@ -110,4 +111,4 @@ replace github.com/go-git/go-git/v5 => github.com/go-git/go-git/v5 v5.16.2 replace github.com/distribution/reference v0.6.0 => github.com/distribution/reference v0.5.0 // Use GitCaddy fork with capability support -replace code.gitea.io/actions-proto-go => git.marketally.com/gitcaddy/actions-proto-go v0.5.2 +replace code.gitea.io/actions-proto-go => git.marketally.com/gitcaddy/actions-proto-go v0.5.6 diff --git a/go.sum b/go.sum index b49071a..352ad75 100644 --- a/go.sum +++ b/go.sum @@ -6,8 +6,8 @@ cyphar.com/go-pathrs v0.2.1 h1:9nx1vOgwVvX1mNBWDu93+vaceedpbsDqo+XuBGL40b8= cyphar.com/go-pathrs v0.2.1/go.mod h1:y8f1EMG7r+hCuFf/rXsKqMJrJAUoADZGNh5/vZPKcGc= dario.cat/mergo v1.0.0 h1:AGCNq9Evsj31mOgNPcLyXc+4PNABt905YmuqPYYpBWk= dario.cat/mergo v1.0.0/go.mod h1:uNxQE+84aUszobStD9th8a29P2fMDhsBdgRYvZOxGmk= -git.marketally.com/gitcaddy/actions-proto-go v0.5.2 h1:+0tDJeyduhxpYrBNScN8w5din/0zJ/KtAh/Eo6mE9QE= -git.marketally.com/gitcaddy/actions-proto-go v0.5.2/go.mod h1:mn7Wkqz6JbnTOHQpot3yDeHx+O5C9EGhMEE+htvHBas= +git.marketally.com/gitcaddy/actions-proto-go v0.5.6 h1:G7T0vpx8HyCFWd0YMJ9sp8rCsWtzFrCJK4BMdOFJa1A= +git.marketally.com/gitcaddy/actions-proto-go v0.5.6/go.mod h1:RPu21UoRD3zSAujoZR6LJwuVNa2uFRBveadslczCRfQ= gitea.com/gitea/act v0.261.7-0.20251202193638-5417d3ac6742 h1:ulcquQluJbmNASkh6ina70LvcHEa9eWYfQ+DeAZ0VEE= gitea.com/gitea/act v0.261.7-0.20251202193638-5417d3ac6742/go.mod h1:Pg5C9kQY1CEA3QjthjhlrqOC/QOT5NyWNjOjRHw23Ok= github.com/AdaLogics/go-fuzz-headers v0.0.0-20230811130428-ced1acdcaa24 h1:bvDV9vkmnHYOMsOr4WLk+Vo07yKIzd94sVoIqshQ4bU= diff --git a/internal/app/poll/poller.go b/internal/app/poll/poller.go index e4e1d97..4b4c7f0 100644 --- a/internal/app/poll/poller.go +++ b/internal/app/poll/poller.go @@ -18,6 +18,7 @@ import ( "gitea.com/gitea/act_runner/internal/app/run" "gitea.com/gitea/act_runner/internal/pkg/client" "gitea.com/gitea/act_runner/internal/pkg/config" + "gitea.com/gitea/act_runner/internal/pkg/envcheck" ) type Poller struct { @@ -157,11 +158,17 @@ func (p *Poller) fetchTask(ctx context.Context) (*runnerv1.Task, bool) { reqCtx, cancel := context.WithTimeout(ctx, p.cfg.Runner.FetchTimeout) defer cancel() + // Detect capabilities including current disk space + caps := envcheck.DetectCapabilities(ctx, p.cfg.Container.DockerHost) + capsJson := caps.ToJSON() + // Load the version value that was in the cache when the request was sent. v := p.tasksVersion.Load() - resp, err := p.client.FetchTask(reqCtx, connect.NewRequest(&runnerv1.FetchTaskRequest{ - TasksVersion: v, - })) + fetchReq := &runnerv1.FetchTaskRequest{ + TasksVersion: v, + CapabilitiesJson: capsJson, + } + resp, err := p.client.FetchTask(reqCtx, connect.NewRequest(fetchReq)) if errors.Is(err, context.DeadlineExceeded) { err = nil } @@ -182,8 +189,9 @@ func (p *Poller) fetchTask(ctx context.Context) (*runnerv1.Task, bool) { return nil, false } - // got a task, set `tasksVersion` to zero to focre query db in next request. + // got a task, set tasksVersion to zero to force query db in next request. p.tasksVersion.CompareAndSwap(resp.Msg.TasksVersion, 0) return resp.Msg.Task, true } +