summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore4
-rw-r--r--contrib/build_rpm.sh2
-rw-r--r--libpod/container_internal_linux.go4
-rw-r--r--test/e2e/checkpoint_test.go43
4 files changed, 51 insertions, 2 deletions
diff --git a/.gitignore b/.gitignore
index 54b63518f..f14f08396 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,7 +1,7 @@
/.artifacts/
/_output/
/brew
-/conmon/conmon.o
+/conmon/
/docs/*.[158]
/docs/*.[158].gz
/docs/remote
@@ -27,3 +27,5 @@ podman-remote*.zip
podman*.tar.gz
.idea*
.vscode*
+contrib/spec/podman.spec
+*.rpm
diff --git a/contrib/build_rpm.sh b/contrib/build_rpm.sh
index 1132ef380..c79e49772 100644
--- a/contrib/build_rpm.sh
+++ b/contrib/build_rpm.sh
@@ -1,5 +1,5 @@
#!/bin/bash
-set -x
+set -euxo pipefail
pkg_manager=`command -v dnf`
if [ -z "$pkg_manager" ]; then
diff --git a/libpod/container_internal_linux.go b/libpod/container_internal_linux.go
index 2ecd5911a..f051f40e9 100644
--- a/libpod/container_internal_linux.go
+++ b/libpod/container_internal_linux.go
@@ -676,6 +676,10 @@ func (c *Container) checkpoint(ctx context.Context, options ContainerCheckpointO
return errors.Wrapf(define.ErrCtrStateInvalid, "%q is not running, cannot checkpoint", c.state.State)
}
+ if c.AutoRemove() && options.TargetFile == "" {
+ return errors.Errorf("Cannot checkpoint containers that have been started with '--rm' unless '--export' is used")
+ }
+
if err := c.checkpointRestoreLabelLog("dump.log"); err != nil {
return err
}
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)
+ })
})