1
0
mirror of https://github.com/woodpecker-ci/woodpecker.git synced 2025-11-23 21:44:44 +02:00

local backend: fix steps having logs form other steps (#5582)

## problem

if steps where started concurrent, the stdout pipeline reader war overwritten and you randomly got the wrong command stream 
from a step.

## change

where we have possible race conditions, we now use thread save types
e.g. store the command struct and the output reader in sync.Map

also a lot of tests where added
This commit is contained in:
6543
2025-10-01 16:58:37 +02:00
committed by GitHub
parent 2a97ae9bcd
commit 44c8921c19
7 changed files with 685 additions and 106 deletions

View File

@@ -100,11 +100,19 @@ func (e *local) execClone(ctx context.Context, step *types.Step, state *workflow
cmd.Env = env
cmd.Dir = state.workspaceDir
// Get output and redirect Stderr to Stdout
e.output, _ = cmd.StdoutPipe()
cmd.Stderr = cmd.Stdout
reader, err := cmd.StdoutPipe()
if err != nil {
return err
}
state.stepCMDs[step.UUID] = cmd
// Save state
state.stepState.Store(step.UUID, &stepState{
cmd: cmd,
output: reader,
})
// Get output and redirect Stderr to Stdout
cmd.Stderr = cmd.Stdout
return cmd.Start()
}