From fc774ac0e5f6b906484723c600f43a66516a208a Mon Sep 17 00:00:00 2001 From: Matthew Heon Date: Tue, 27 Nov 2018 10:23:10 -0500 Subject: Stopping a stopped container is not an error for Podman Signed-off-by: Matthew Heon --- cmd/podman/stop.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/cmd/podman/stop.go b/cmd/podman/stop.go index 04022839a..ade51705e 100644 --- a/cmd/podman/stop.go +++ b/cmd/podman/stop.go @@ -2,6 +2,7 @@ package main import ( "fmt" + "github.com/containers/libpod/cmd/podman/libpodruntime" "github.com/containers/libpod/cmd/podman/shared" "github.com/containers/libpod/libpod" @@ -77,7 +78,11 @@ func stopCmd(c *cli.Context) error { stopTimeout = ctr.StopTimeout() } f := func() error { - return con.StopWithTimeout(stopTimeout) + if err := con.StopWithTimeout(stopTimeout); err != nil && errors.Cause(err) != libpod.ErrCtrStopped { + return err + } + return nil + } stopFuncs = append(stopFuncs, shared.ParallelWorkerInput{ ContainerID: con.ID(), -- cgit v1.2.3-54-g00ecf From 841f47d728fd1049456012a03b9b4e66407f9489 Mon Sep 17 00:00:00 2001 From: Matthew Heon Date: Tue, 27 Nov 2018 10:31:56 -0500 Subject: Add test to ensure stopping a stopped container works We regressed on this at some point. Adding a new test should help ensure that doesn't happen again. Signed-off-by: Matthew Heon --- test/e2e/stop_test.go | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/test/e2e/stop_test.go b/test/e2e/stop_test.go index b172cd81e..5c229b9b4 100644 --- a/test/e2e/stop_test.go +++ b/test/e2e/stop_test.go @@ -57,6 +57,20 @@ var _ = Describe("Podman stop", func() { Expect(session.ExitCode()).To(Equal(0)) }) + It("podman stop stopped container", func() { + session := podmanTest.RunTopContainer("test1") + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) + + session2 := podmanTest.Podman([]string{"stop", "test1"}) + session2.WaitWithDefaultTimeout() + Expect(session2.ExitCode()).To(Equal(0)) + + session3 := podmanTest.Podman([]string{"stop", "test1"}) + session3.WaitWithDefaultTimeout() + Expect(session3.ExitCode()).To(Equal(0)) + }) + It("podman stop all containers", func() { session := podmanTest.RunTopContainer("test1") session.WaitWithDefaultTimeout() -- cgit v1.2.3-54-g00ecf