Skip to content

Commit 306c92b

Browse files
authored
Merge pull request #137 from linuxboot/fix/race_condition_in_step_runners_error_propagation
Fix race condition in step runner's run error propagation
2 parents 87e0e9f + 6ab9a19 commit 306c92b

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

pkg/runner/step_state.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,13 +145,18 @@ func (ss *stepState) Run(ctx xcontext.Context) error {
145145

146146
go func() {
147147
defer func() {
148+
// There could be a race condition when due to error in step runner, TestRunner gets the error earlier
149+
// than it is propagated here and cancels stepCtx
150+
if runErr := ss.stepRunner.getErr(); runErr != nil {
151+
ss.SetError(ctx, runErr)
152+
}
148153
close(ss.stopped)
149154
stepCtx.Debugf("StepRunner fully stopped")
150155
}()
151156

152157
select {
153158
case stepErr := <-stepRunResult.NotifyCh():
154-
ss.SetError(stepCtx, stepErr)
159+
ss.SetError(ctx, stepErr)
155160
case <-stepCtx.Done():
156161
stepCtx.Debugf("Cancelled step context during waiting for step run result")
157162
}

0 commit comments

Comments
 (0)