Skip to content

Commit

Permalink
Warn if podman stop timeout expires that sigkill was sent
Browse files Browse the repository at this point in the history
Also fix podman man page to appropriately note that we run
with log-level warn.

Note: the Warning message will not come to podman-remote.
It would be difficult to plumb, and not really worth the effort.

Fixes: containers#11854

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
  • Loading branch information
rhatdan committed Oct 6, 2021
1 parent bfb904b commit 462385a
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
2 changes: 1 addition & 1 deletion docs/source/markdown/podman.1.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ Remote connections use local containers.conf for default.

#### **--log-level**=*level*

Log messages above specified level: debug, info, warn, error (default), fatal or panic (default: "error")
Log messages above specified level: debug, info, warn, error (default), fatal or panic (default: "warn")

#### **--namespace**=*namespace*

Expand Down
2 changes: 1 addition & 1 deletion libpod/oci_conmon_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -441,7 +441,7 @@ 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.Warnf("Timed out stopping container %s, resorting to SIGKILL: %v", ctr.ID(), err)
} else {
// No error, the container is dead
return nil
Expand Down
12 changes: 12 additions & 0 deletions test/e2e/stop_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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("Timed out stopping container"))
})

It("podman stop latest containers", func() {
SkipIfRemote("--latest flag n/a")
session := podmanTest.RunTopContainer("test1")
Expand Down

0 comments on commit 462385a

Please sign in to comment.