mirror of
https://github.com/containers/podman.git
synced 2025-06-29 23:22:40 +08:00
Merge pull request #11880 from rhatdan/stoptimeout
Warn if podman stop timeout expires that sigkill was sent
This commit is contained in:
@ -441,7 +441,8 @@ func (r *ConmonOCIRuntime) StopContainer(ctr *Container, timeout uint, all bool)
|
||||
}
|
||||
|
||||
if err := waitContainerStop(ctr, time.Duration(timeout)*time.Second); err != nil {
|
||||
logrus.Infof("Timed out stopping container %s, resorting to SIGKILL: %v", ctr.ID(), err)
|
||||
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)
|
||||
} else {
|
||||
// No error, the container is dead
|
||||
return nil
|
||||
|
@ -181,6 +181,18 @@ var _ = Describe("Podman stop", func() {
|
||||
Expect(strings.TrimSpace(finalCtrs.OutputToString())).To(Equal(""))
|
||||
})
|
||||
|
||||
It("podman stop container --timeout Warning", func() {
|
||||
SkipIfRemote("warning will happen only on server side")
|
||||
session := podmanTest.Podman([]string{"run", "-d", "--name", "test5", ALPINE, "sleep", "100"})
|
||||
session.WaitWithDefaultTimeout()
|
||||
Expect(session).Should(Exit(0))
|
||||
session = podmanTest.Podman([]string{"stop", "--timeout", "1", "test5"})
|
||||
session.WaitWithDefaultTimeout()
|
||||
Expect(session).Should(Exit(0))
|
||||
warning := session.ErrorToString()
|
||||
Expect(warning).To(ContainSubstring("StopSignal SIGTERM failed to stop container test5 in 1 seconds, resorting to SIGKILL"))
|
||||
})
|
||||
|
||||
It("podman stop latest containers", func() {
|
||||
SkipIfRemote("--latest flag n/a")
|
||||
session := podmanTest.RunTopContainer("test1")
|
||||
|
@ -166,4 +166,11 @@ load helpers
|
||||
is "$output" "137" "Exit code of killed container"
|
||||
}
|
||||
|
||||
@test "podman stop -t 1 Generate warning" {
|
||||
skip_if_remote "warning only happens on server side"
|
||||
run_podman run --rm --name stopme -d $IMAGE sleep 100
|
||||
run_podman stop -t 1 stopme
|
||||
is "$output" ".*StopSignal SIGTERM failed to stop container stopme in 1 seconds, resorting to SIGKILL" "stopping container should print warning"
|
||||
}
|
||||
|
||||
# vim: filetype=sh
|
||||
|
Reference in New Issue
Block a user