mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2026-04-15 01:41:56 +00: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 {
|
||||
case resp := <-wait.Result:
|
||||
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:
|
||||
log.Trace().Msgf("ContainerWait returned with err: %v", err)
|
||||
return nil, err
|
||||
case <-ctx.Done():
|
||||
return nil, ctx.Err()
|
||||
}
|
||||
@@ -290,9 +294,15 @@ func (e *docker) WaitStep(ctx context.Context, step *backend_types.Step, taskUUI
|
||||
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{
|
||||
Exited: true,
|
||||
ExitCode: info.Container.State.ExitCode,
|
||||
ExitCode: exitCode,
|
||||
OOMKilled: info.Container.State.OOMKilled,
|
||||
}, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user