1
0
mirror of https://github.com/woodpecker-ci/woodpecker.git synced 2026-06-03 16:35:37 +02:00

Fix race in pipeline runtime (#6451)

as step tracer is also used to update workflow environment variables
This commit is contained in:
6543
2026-04-16 00:41:39 +02:00
committed by GitHub
parent a025e4cff4
commit 4390796985
2 changed files with 9 additions and 2 deletions
+3
View File
@@ -16,6 +16,7 @@ package runtime
import (
"context"
"sync"
"github.com/oklog/ulid/v2"
"github.com/rs/zerolog"
@@ -43,6 +44,7 @@ type Runtime struct {
ctx context.Context
tracer tracing.Tracer
tracerLock sync.Mutex
logger logging.Logger
taskUUID string
@@ -58,6 +60,7 @@ func New(spec *backend_types.Config, backend backend_types.Backend, opts ...Opti
r.engine = backend
r.ctx = context.Background()
r.taskUUID = ulid.Make().String()
r.tracerLock = sync.Mutex{}
for _, opt := range opts {
opt(r)
}
+4
View File
@@ -253,6 +253,10 @@ func (r *Runtime) traceStep(processState *backend_types.State, err error, step *
// processState == nil && err == nil: step just started, leave s.CurrStepState zero-valued.
}
// The tracer should just trace changes, but it currently also updates step env vars used in various ways:
// https://github.com/woodpecker-ci/woodpecker/blob/main/agent/tracer.go#L79-L86 .
r.tracerLock.Lock()
defer r.tracerLock.Unlock()
if traceErr := r.tracer.Trace(s); traceErr != nil {
return traceErr
}