mirror of
https://github.com/containers/podman.git
synced 2025-12-03 19:59:39 +08:00
Remove containers when pruning a stopped pod.
This path allows pod prune & pod rm to remove stopped containers in the pod before deleting the pod. PrunePods and RemovePod should be able to remove containers without force removal of stopped pods. Signed-off-by: Qi Wang <qiwan@redhat.com>
This commit is contained in:
@@ -41,7 +41,24 @@ var _ = Describe("Podman pod prune", func() {
|
||||
Expect(result.ExitCode()).To(Equal(0))
|
||||
})
|
||||
|
||||
It("podman pod prune doesn't remove a pod with a container", func() {
|
||||
It("podman pod prune doesn't remove a pod with a running container", func() {
|
||||
_, ec, podid := podmanTest.CreatePod("")
|
||||
Expect(ec).To(Equal(0))
|
||||
|
||||
ec2 := podmanTest.RunTopContainerInPod("", podid)
|
||||
ec2.WaitWithDefaultTimeout()
|
||||
Expect(ec2.ExitCode()).To(Equal(0))
|
||||
|
||||
result := podmanTest.Podman([]string{"pod", "prune"})
|
||||
result.WaitWithDefaultTimeout()
|
||||
Expect(result.ExitCode()).To((Equal(0)))
|
||||
|
||||
result = podmanTest.Podman([]string{"ps", "-qa"})
|
||||
result.WaitWithDefaultTimeout()
|
||||
Expect(len(result.OutputToStringArray())).To(Equal(1))
|
||||
})
|
||||
|
||||
It("podman pod prune removes a pod with a stopped container", func() {
|
||||
_, ec, podid := podmanTest.CreatePod("")
|
||||
Expect(ec).To(Equal(0))
|
||||
|
||||
@@ -50,11 +67,11 @@ var _ = Describe("Podman pod prune", func() {
|
||||
|
||||
result := podmanTest.Podman([]string{"pod", "prune"})
|
||||
result.WaitWithDefaultTimeout()
|
||||
Expect(result.ExitCode()).To(Equal(125))
|
||||
Expect(result.ExitCode()).To(Equal(0))
|
||||
|
||||
result = podmanTest.Podman([]string{"ps", "-qa"})
|
||||
result.WaitWithDefaultTimeout()
|
||||
Expect(len(result.OutputToStringArray())).To(Equal(1))
|
||||
Expect(len(result.OutputToStringArray())).To(Equal(0))
|
||||
})
|
||||
|
||||
It("podman pod prune -f does remove a running container", func() {
|
||||
|
||||
@@ -77,7 +77,7 @@ var _ = Describe("Podman pod rm", func() {
|
||||
Expect(result.OutputToString()).To(Not(ContainSubstring(podid2)))
|
||||
})
|
||||
|
||||
It("podman pod rm doesn't remove a pod with a container", func() {
|
||||
It("podman pod rm removes a pod with a container", func() {
|
||||
_, ec, podid := podmanTest.CreatePod("")
|
||||
Expect(ec).To(Equal(0))
|
||||
|
||||
@@ -86,11 +86,11 @@ var _ = Describe("Podman pod rm", func() {
|
||||
|
||||
result := podmanTest.Podman([]string{"pod", "rm", podid})
|
||||
result.WaitWithDefaultTimeout()
|
||||
Expect(result.ExitCode()).To(Equal(125))
|
||||
Expect(result.ExitCode()).To(Equal(0))
|
||||
|
||||
result = podmanTest.Podman([]string{"ps", "-qa"})
|
||||
result.WaitWithDefaultTimeout()
|
||||
Expect(len(result.OutputToStringArray())).To(Equal(1))
|
||||
Expect(len(result.OutputToStringArray())).To(Equal(0))
|
||||
})
|
||||
|
||||
It("podman pod rm -f does remove a running container", func() {
|
||||
@@ -136,7 +136,7 @@ var _ = Describe("Podman pod rm", func() {
|
||||
result := podmanTest.Podman([]string{"pod", "rm", "-a"})
|
||||
result.WaitWithDefaultTimeout()
|
||||
Expect(result).To(ExitWithError())
|
||||
foundExpectedError, _ := result.ErrorGrepString("contains containers and cannot be removed")
|
||||
foundExpectedError, _ := result.ErrorGrepString("cannot be removed")
|
||||
Expect(foundExpectedError).To(Equal(true))
|
||||
|
||||
num_pods = podmanTest.NumberOfPods()
|
||||
|
||||
Reference in New Issue
Block a user