Merge pull request #15716 from vrothberg/fix-15661

stop: fix error handling
This commit is contained in:
OpenShift Merge Robot 2022-09-09 16:04:46 +02:00 committed by GitHub
commit 04082333a6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 4 deletions

View File

@ -429,13 +429,11 @@ func (r *ConmonOCIRuntime) StopContainer(ctr *Container, timeout uint, all bool)
}
}
if err := r.KillContainer(ctr, 9, all); err != nil {
if err := r.KillContainer(ctr, uint(unix.SIGKILL), all); err != nil {
// Again, check if the container is gone. If it is, exit cleanly.
err := unix.Kill(ctr.state.PID, 0)
if err == unix.ESRCH {
if aliveErr := unix.Kill(ctr.state.PID, 0); errors.Is(aliveErr, unix.ESRCH) {
return nil
}
return fmt.Errorf("error sending SIGKILL to container %s: %w", ctr.ID(), err)
}