Skip to content

Commit

Permalink
Merge pull request #19892 from edsantiago/StopSignal_default_name
Browse files Browse the repository at this point in the history
StopContainer: display signal num when name unknown
  • Loading branch information
vrothberg committed Sep 8, 2023
2 parents c0d36b8 + 70cf974 commit 5d6ec27
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
8 changes: 6 additions & 2 deletions libpod/oci_conmon_common.go
Original file line number Diff line number Diff line change
Expand Up @@ -473,8 +473,12 @@ func (r *ConmonOCIRuntime) StopContainer(ctr *Container, timeout uint, all bool)
}

if err := waitContainerStop(ctr, time.Duration(util.ConvertTimeout(int(timeout)))*time.Second); err != nil {
logrus.Debugf("Timed out stopping container %s with %s, resorting to SIGKILL: %v", ctr.ID(), unix.SignalName(syscall.Signal(stopSignal)), err)
logrus.Warnf("StopSignal %s failed to stop container %s in %d seconds, resorting to SIGKILL", unix.SignalName(syscall.Signal(stopSignal)), ctr.Name(), timeout)
sigName := unix.SignalName(syscall.Signal(stopSignal))
if sigName == "" {
sigName = fmt.Sprintf("(%d)", stopSignal)
}
logrus.Debugf("Timed out stopping container %s with %s, resorting to SIGKILL: %v", ctr.ID(), sigName, err)
logrus.Warnf("StopSignal %s failed to stop container %s in %d seconds, resorting to SIGKILL", sigName, ctr.Name(), timeout)
} else {
// No error, the container is dead
return nil
Expand Down
3 changes: 1 addition & 2 deletions test/system/030-run.bats
Original file line number Diff line number Diff line change
Expand Up @@ -1058,11 +1058,10 @@ $IMAGE--c_ok" \
"ls /dev/tty[0-9] with --systemd=always: should have no ttyN devices"

# Make sure run_podman stop supports -1 option
# FIXME: why is there no signal name here? Should be 'StopSignal XYZ'
# FIXME: do we really really mean to say FFFFFFFFFFFFFFFF here???
run_podman 0+w stop -t -1 $cid
if ! is_remote; then
assert "$output" =~ "StopSignal failed to stop container .* in 18446744073709551615 seconds, resorting to SIGKILL" "stop -t -1 (negative one) issues warning"
assert "$output" =~ "StopSignal \(37\) failed to stop container .* in 18446744073709551615 seconds, resorting to SIGKILL" "stop -t -1 (negative one) issues warning"
fi
run_podman rm -t -1 -f $cid
}
Expand Down

0 comments on commit 5d6ec27

Please sign in to comment.