diff options
author | Adrian Reber <areber@redhat.com> | 2019-11-28 19:04:35 +0000 |
---|---|---|
committer | Adrian Reber <areber@redhat.com> | 2019-11-28 20:25:45 +0100 |
commit | 5e43c7cde1da185f3a9dc4f949e778b087d4ea42 (patch) | |
tree | b5c48de998e469a17ca94788db81bceb0a289865 /test | |
parent | aa95726c98385fb75bc70b6de7a86c09ed74abd5 (diff) | |
download | podman-5e43c7cde1da185f3a9dc4f949e778b087d4ea42.tar.gz podman-5e43c7cde1da185f3a9dc4f949e778b087d4ea42.tar.bz2 podman-5e43c7cde1da185f3a9dc4f949e778b087d4ea42.zip |
Disable checkpointing of containers started with --rm
Trying to checkpoint a container started with --rm works, but it makes
no sense as the container, including the checkpoint, will be deleted
after writing the checkpoint. This commit inhibits checkpointing
containers started with '--rm' unless '--export' is used. If the
checkpoint is exported it can easily be restored from the exported
checkpoint, even if '--rm' is used. To restore a container from a
checkpoint it is even necessary to manually run 'podman rm' if the
container is not started with '--rm'.
Signed-off-by: Adrian Reber <areber@redhat.com>
Diffstat (limited to 'test')
-rw-r--r-- | test/e2e/checkpoint_test.go | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/test/e2e/checkpoint_test.go b/test/e2e/checkpoint_test.go index 2d3efcbef..f208a4cf0 100644 --- a/test/e2e/checkpoint_test.go +++ b/test/e2e/checkpoint_test.go @@ -588,4 +588,47 @@ var _ = Describe("Podman checkpoint", func() { // Remove exported checkpoint os.Remove(fileName) }) + + It("podman checkpoint a container started with --rm", func() { + // Start the container + localRunString := getRunString([]string{"--rm", ALPINE, "top"}) + session := podmanTest.Podman(localRunString) + session.WaitWithDefaultTimeout() + cid := session.OutputToString() + Expect(podmanTest.NumberOfContainersRunning()).To(Equal(1)) + + // Checkpoint the container - this should fail as it was started with --rm + result := podmanTest.Podman([]string{"container", "checkpoint", "-l"}) + result.WaitWithDefaultTimeout() + Expect(result).To(ExitWithError()) + Expect(result.ErrorToString()).To(ContainSubstring("Cannot checkpoint containers that have been started with '--rm'")) + + // Checkpointing with --export should still work + fileName := "/tmp/checkpoint-" + cid + ".tar.gz" + + result = podmanTest.Podman([]string{"container", "checkpoint", "-l", "-e", fileName}) + result.WaitWithDefaultTimeout() + + // As the container has been started with '--rm' it will be completely + // cleaned up after checkpointing. + Expect(result.ExitCode()).To(Equal(0)) + Expect(podmanTest.NumberOfContainersRunning()).To(Equal(0)) + Expect(podmanTest.NumberOfContainers()).To(Equal(0)) + + result = podmanTest.Podman([]string{"container", "restore", "-i", fileName}) + result.WaitWithDefaultTimeout() + + Expect(result.ExitCode()).To(Equal(0)) + Expect(podmanTest.NumberOfContainersRunning()).To(Equal(1)) + Expect(podmanTest.GetContainerStatus()).To(ContainSubstring("Up")) + + result = podmanTest.Podman([]string{"rm", "-fa"}) + result.WaitWithDefaultTimeout() + Expect(result.ExitCode()).To(Equal(0)) + Expect(podmanTest.NumberOfContainersRunning()).To(Equal(0)) + Expect(podmanTest.NumberOfContainers()).To(Equal(0)) + + // Remove exported checkpoint + os.Remove(fileName) + }) }) |