You've already forked woodpecker
mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2026-06-03 16:35:37 +02:00
Fix Windows container exit code handling and error checks (#6411)
This commit is contained in:
@@ -279,8 +279,12 @@ func (e *docker) WaitStep(ctx context.Context, step *backend_types.Step, taskUUI
|
|||||||
select {
|
select {
|
||||||
case resp := <-wait.Result:
|
case resp := <-wait.Result:
|
||||||
log.Trace().Msgf("ContainerWait returned with resp: %v", resp)
|
log.Trace().Msgf("ContainerWait returned with resp: %v", resp)
|
||||||
|
if resp.Error != nil {
|
||||||
|
return nil, fmt.Errorf("ContainerWait error: %s", resp.Error.Message)
|
||||||
|
}
|
||||||
case err := <-wait.Error:
|
case err := <-wait.Error:
|
||||||
log.Trace().Msgf("ContainerWait returned with err: %v", err)
|
log.Trace().Msgf("ContainerWait returned with err: %v", err)
|
||||||
|
return nil, err
|
||||||
case <-ctx.Done():
|
case <-ctx.Done():
|
||||||
return nil, ctx.Err()
|
return nil, ctx.Err()
|
||||||
}
|
}
|
||||||
@@ -290,9 +294,15 @@ func (e *docker) WaitStep(ctx context.Context, step *backend_types.Step, taskUUI
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
exitCode := info.Container.State.ExitCode
|
||||||
|
// Windows Docker may return 4294967295 (uint32 max, i.e. int32(-1)) for abnormal exits.
|
||||||
|
if exitCode == int(^uint32(0)) {
|
||||||
|
exitCode = int(int32(exitCode))
|
||||||
|
}
|
||||||
|
|
||||||
return &backend_types.State{
|
return &backend_types.State{
|
||||||
Exited: true,
|
Exited: true,
|
||||||
ExitCode: info.Container.State.ExitCode,
|
ExitCode: exitCode,
|
||||||
OOMKilled: info.Container.State.OOMKilled,
|
OOMKilled: info.Container.State.OOMKilled,
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user