From f437078d2b858332f3af33dbc093e2dc7210789e Mon Sep 17 00:00:00 2001 From: Daniel J Walsh Date: Thu, 6 Oct 2022 17:16:42 -0400 Subject: [PATCH 1/2] Revert "cmd/podman: add support for checkpoint images" This reverts commit 9c3d8bb494f358ecff785ba81a58f2e05f1a98a1. Signed-off-by: Daniel J Walsh --- cmd/podman/containers/restore.go | 14 +++++++------- cmd/podman/containers/run.go | 29 ----------------------------- 2 files changed, 7 insertions(+), 36 deletions(-) diff --git a/cmd/podman/containers/restore.go b/cmd/podman/containers/restore.go index 144925a54d..d094ac2469 100644 --- a/cmd/podman/containers/restore.go +++ b/cmd/podman/containers/restore.go @@ -93,7 +93,7 @@ func init() { func restore(cmd *cobra.Command, args []string) error { var ( - err error + e error errs utils.OutputErrors ) podmanStart := time.Now() @@ -104,9 +104,9 @@ func restore(cmd *cobra.Command, args []string) error { // Check if the container exists (#15055) exists := &entities.BoolReport{Value: false} for _, ctr := range args { - exists, err = registry.ContainerEngine().ContainerExists(registry.GetContext(), ctr, entities.ContainerExistsOptions{}) - if err != nil { - return err + exists, e = registry.ContainerEngine().ContainerExists(registry.GetContext(), ctr, entities.ContainerExistsOptions{}) + if e != nil { + return e } if exists.Value { break @@ -115,9 +115,9 @@ func restore(cmd *cobra.Command, args []string) error { if !exists.Value { // Find out if this is an image - restoreOptions.CheckpointImage, err = utils.IsCheckpointImage(context.Background(), args) - if err != nil { - return err + restoreOptions.CheckpointImage, e = utils.IsCheckpointImage(context.Background(), args) + if e != nil { + return e } } diff --git a/cmd/podman/containers/run.go b/cmd/podman/containers/run.go index d8d020c635..f66d4d4d34 100644 --- a/cmd/podman/containers/run.go +++ b/cmd/podman/containers/run.go @@ -148,35 +148,6 @@ func run(cmd *cobra.Command, args []string) error { imageName = name } - // If this is a checkpoint image, invoke container restore. - // We do not return `err` when checkpointImage is false, because the value - // of `err` could be "image is not a checkpoint". In this case, the run - // command should continue as usual, preserving backwards compatibility. - checkpointImage, err := utils.IsCheckpointImage(registry.GetContext(), []string{imageName}) - if checkpointImage { - if err != nil { - return err - } - var restoreOptions entities.RestoreOptions - responses, err := registry.ContainerEngine().ContainerRestore(registry.GetContext(), []string{imageName}, restoreOptions) - if err != nil { - return err - } - - var errs utils.OutputErrors - for _, r := range responses { - switch { - case r.Err != nil: - errs = append(errs, r.Err) - case r.RawInput != "": - fmt.Println(r.RawInput) - default: - fmt.Println(r.Id) - } - } - return errs.PrintErrors() - } - if cliVals.Replace { if err := replaceContainer(cliVals.Name); err != nil { return err From b47b48fd03eaa05fb15c77491984be077eee39e3 Mon Sep 17 00:00:00 2001 From: Daniel J Walsh Date: Tue, 11 Oct 2022 07:56:56 -0400 Subject: [PATCH 2/2] Revert "Add checkpoint image tests" This reverts commit bbe1063a5ae681ad04a049518c6087421b919f2e. Signed-off-by: Daniel J Walsh --- docs/source/markdown/podman-kube-play.1.md.in | 2 +- test/e2e/checkpoint_image_test.go | 346 ------------------ 2 files changed, 1 insertion(+), 347 deletions(-) delete mode 100644 test/e2e/checkpoint_image_test.go diff --git a/docs/source/markdown/podman-kube-play.1.md.in b/docs/source/markdown/podman-kube-play.1.md.in index dea47c3074..8ff7bc5310 100644 --- a/docs/source/markdown/podman-kube-play.1.md.in +++ b/docs/source/markdown/podman-kube-play.1.md.in @@ -233,7 +233,7 @@ Pods removed: `podman kube play --down` will not work with a URL if the YAML file the URL points to has been changed or altered. - +@@option tls-verify ## SEE ALSO **[podman(1)](podman.1.md)**, **[podman-kube(1)](podman-kube.1.md)**, **[podman-kube-down(1)](podman-kube-down.1.md)**, **[podman-network-create(1)](podman-network-create.1.md)**, **[podman-kube-generate(1)](podman-kube-generate.1.md)**, **[containers-certs.d(5)](https://github.com/containers/image/blob/main/docs/containers-certs.d.5.md)** diff --git a/test/e2e/checkpoint_image_test.go b/test/e2e/checkpoint_image_test.go deleted file mode 100644 index 7ab0b5ca58..0000000000 --- a/test/e2e/checkpoint_image_test.go +++ /dev/null @@ -1,346 +0,0 @@ -package integration - -import ( - "os" - "os/exec" - "strconv" - "strings" - - "github.com/containers/podman/v4/pkg/criu" - . "github.com/containers/podman/v4/test/utils" - . "github.com/onsi/ginkgo" - . "github.com/onsi/gomega" - . "github.com/onsi/gomega/gexec" -) - -var _ = Describe("Podman checkpoint", func() { - var ( - tempdir string - err error - podmanTest *PodmanTestIntegration - ) - - BeforeEach(func() { - SkipIfRootless("checkpoint not supported in rootless mode") - tempdir, err = CreateTempDirInTempDir() - if err != nil { - os.Exit(1) - } - podmanTest = PodmanTestCreate(tempdir) - podmanTest.Setup() - // Check if the runtime implements checkpointing. Currently only - // runc's checkpoint/restore implementation is supported. - cmd := exec.Command(podmanTest.OCIRuntime, "checkpoint", "--help") - if err := cmd.Start(); err != nil { - Skip("OCI runtime does not support checkpoint/restore") - } - if err := cmd.Wait(); err != nil { - Skip("OCI runtime does not support checkpoint/restore") - } - - if !criu.CheckForCriu(criu.MinCriuVersion) { - Skip("CRIU is missing or too old.") - } - }) - - AfterEach(func() { - podmanTest.Cleanup() - f := CurrentGinkgoTestDescription() - processTestResult(f) - }) - - It("podman checkpoint --create-image with bogus container", func() { - checkpointImage := "foobar-checkpoint" - session := podmanTest.Podman([]string{"container", "checkpoint", "--create-image", checkpointImage, "foobar"}) - session.WaitWithDefaultTimeout() - Expect(session).To(ExitWithError()) - Expect(session.ErrorToString()).To(ContainSubstring("no container with name or ID \"foobar\" found")) - }) - - It("podman checkpoint --create-image with running container", func() { - SkipIfContainerized("FIXME: #15015. All checkpoint tests hang when containerized.") - // Container image must be lowercase - checkpointImage := "alpine-checkpoint-" + strings.ToLower(RandomString(6)) - containerName := "alpine-container-" + RandomString(6) - - localRunString := []string{ - "run", - "-it", - "-d", - "--ip", GetRandomIPAddress(), - "--name", containerName, - ALPINE, - "top", - } - session := podmanTest.Podman(localRunString) - session.WaitWithDefaultTimeout() - Expect(session).Should(Exit(0)) - containerID := session.OutputToString() - - // Checkpoint image should not exist - session = podmanTest.Podman([]string{"images"}) - session.WaitWithDefaultTimeout() - Expect(session).Should(Exit(0)) - Expect(session.LineInOutputContainsTag("localhost/"+checkpointImage, "latest")).To(BeFalse()) - - // Check if none of the checkpoint/restore specific information is displayed - // for newly started containers. - inspect := podmanTest.Podman([]string{"inspect", containerID}) - inspect.WaitWithDefaultTimeout() - Expect(inspect).Should(Exit(0)) - inspectOut := inspect.InspectContainerToJSON() - Expect(inspectOut[0].State.Checkpointed).To(BeFalse(), ".State.Checkpointed") - Expect(inspectOut[0].State.Restored).To(BeFalse(), ".State.Restored") - Expect(inspectOut[0].State).To(HaveField("CheckpointPath", "")) - Expect(inspectOut[0].State).To(HaveField("CheckpointLog", "")) - Expect(inspectOut[0].State).To(HaveField("RestoreLog", "")) - - result := podmanTest.Podman([]string{"container", "checkpoint", "--create-image", checkpointImage, "--keep", containerID}) - result.WaitWithDefaultTimeout() - - Expect(result).Should(Exit(0)) - Expect(podmanTest.NumberOfContainersRunning()).To(Equal(0)) - Expect(podmanTest.GetContainerStatus()).To(ContainSubstring("Exited")) - - inspect = podmanTest.Podman([]string{"inspect", containerID}) - inspect.WaitWithDefaultTimeout() - Expect(inspect).Should(Exit(0)) - inspectOut = inspect.InspectContainerToJSON() - Expect(inspectOut[0].State.Checkpointed).To(BeTrue(), ".State.Checkpointed") - Expect(inspectOut[0].State.CheckpointPath).To(ContainSubstring("userdata/checkpoint")) - Expect(inspectOut[0].State.CheckpointLog).To(ContainSubstring("userdata/dump.log")) - - // Check if checkpoint image has been created - session = podmanTest.Podman([]string{"images"}) - session.WaitWithDefaultTimeout() - Expect(session).Should(Exit(0)) - Expect(session.LineInOutputContainsTag("localhost/"+checkpointImage, "latest")).To(BeTrue()) - - // Check if the checkpoint image contains annotations - inspect = podmanTest.Podman([]string{"inspect", checkpointImage}) - inspect.WaitWithDefaultTimeout() - Expect(inspect).Should(Exit(0)) - inspectImageOut := inspect.InspectImageJSON() - Expect(inspectImageOut[0].Annotations["io.podman.annotations.checkpoint.name"]).To( - BeEquivalentTo(containerName), - "io.podman.annotations.checkpoint.name", - ) - - ociRuntimeName := "" - if strings.Contains(podmanTest.OCIRuntime, "runc") { - ociRuntimeName = "runc" - } else if strings.Contains(podmanTest.OCIRuntime, "crun") { - ociRuntimeName = "crun" - } - if ociRuntimeName != "" { - Expect(inspectImageOut[0].Annotations["io.podman.annotations.checkpoint.runtime.name"]).To( - BeEquivalentTo(ociRuntimeName), - "io.podman.annotations.checkpoint.runtime.name", - ) - } - - // Remove existing container - result = podmanTest.Podman([]string{"rm", "-t", "1", "-f", containerID}) - result.WaitWithDefaultTimeout() - Expect(result).Should(Exit(0)) - - // Restore container from checkpoint image - result = podmanTest.Podman([]string{"container", "restore", checkpointImage}) - result.WaitWithDefaultTimeout() - - Expect(result).Should(Exit(0)) - Expect(podmanTest.NumberOfContainersRunning()).To(Equal(1)) - Expect(podmanTest.GetContainerStatus()).To(ContainSubstring("Up")) - - // Clean-up - result = podmanTest.Podman([]string{"rm", "-t", "0", "-fa"}) - result.WaitWithDefaultTimeout() - Expect(result).Should(Exit(0)) - Expect(podmanTest.NumberOfContainersRunning()).To(Equal(0)) - - result = podmanTest.Podman([]string{"rmi", checkpointImage}) - result.WaitWithDefaultTimeout() - Expect(result).Should(Exit(0)) - Expect(podmanTest.NumberOfContainersRunning()).To(Equal(0)) - }) - - It("podman restore multiple containers from single checkpoint image", func() { - SkipIfContainerized("FIXME: #15015. All checkpoint tests hang when containerized.") - // Container image must be lowercase - checkpointImage := "alpine-checkpoint-" + strings.ToLower(RandomString(6)) - containerName := "alpine-container-" + RandomString(6) - - localRunString := []string{"run", "-d", "--name", containerName, ALPINE, "top"} - session := podmanTest.Podman(localRunString) - session.WaitWithDefaultTimeout() - Expect(session).Should(Exit(0)) - containerID := session.OutputToString() - - // Checkpoint image should not exist - session = podmanTest.Podman([]string{"images"}) - session.WaitWithDefaultTimeout() - Expect(session).Should(Exit(0)) - Expect(session.LineInOutputContainsTag("localhost/"+checkpointImage, "latest")).To(BeFalse()) - - result := podmanTest.Podman([]string{"container", "checkpoint", "--create-image", checkpointImage, "--keep", containerID}) - result.WaitWithDefaultTimeout() - - Expect(result).Should(Exit(0)) - Expect(podmanTest.NumberOfContainersRunning()).To(Equal(0)) - Expect(podmanTest.GetContainerStatus()).To(ContainSubstring("Exited")) - - // Check if checkpoint image has been created - session = podmanTest.Podman([]string{"images"}) - session.WaitWithDefaultTimeout() - Expect(session).Should(Exit(0)) - Expect(session.LineInOutputContainsTag("localhost/"+checkpointImage, "latest")).To(BeTrue()) - - // Remove existing container - result = podmanTest.Podman([]string{"rm", "-t", "1", "-f", containerID}) - result.WaitWithDefaultTimeout() - Expect(result).Should(Exit(0)) - - for i := 1; i < 5; i++ { - // Restore container from checkpoint image - name := containerName + strconv.Itoa(i) - result = podmanTest.Podman([]string{"container", "restore", "--name", name, checkpointImage}) - result.WaitWithDefaultTimeout() - Expect(result).Should(Exit(0)) - Expect(podmanTest.NumberOfContainersRunning()).To(Equal(i)) - - // Check that the container is running - status := podmanTest.Podman([]string{"inspect", name, "--format={{.State.Status}}"}) - status.WaitWithDefaultTimeout() - Expect(status).Should(Exit(0)) - Expect(status.OutputToString()).To(Equal("running")) - } - - // Clean-up - result = podmanTest.Podman([]string{"rm", "-t", "0", "-fa"}) - result.WaitWithDefaultTimeout() - Expect(result).Should(Exit(0)) - Expect(podmanTest.NumberOfContainersRunning()).To(Equal(0)) - - result = podmanTest.Podman([]string{"rmi", checkpointImage}) - result.WaitWithDefaultTimeout() - Expect(result).Should(Exit(0)) - Expect(podmanTest.NumberOfContainersRunning()).To(Equal(0)) - }) - - It("podman restore multiple containers from multiple checkpoint images", func() { - SkipIfContainerized("FIXME: #15015. All checkpoint tests hang when containerized.") - // Container image must be lowercase - checkpointImage1 := "alpine-checkpoint-" + strings.ToLower(RandomString(6)) - checkpointImage2 := "alpine-checkpoint-" + strings.ToLower(RandomString(6)) - containerName1 := "alpine-container-" + RandomString(6) - containerName2 := "alpine-container-" + RandomString(6) - - // Create first container - localRunString := []string{"run", "-d", "--name", containerName1, ALPINE, "top"} - session := podmanTest.Podman(localRunString) - session.WaitWithDefaultTimeout() - Expect(session).Should(Exit(0)) - containerID1 := session.OutputToString() - - // Create second container - localRunString = []string{"run", "-d", "--name", containerName2, ALPINE, "top"} - session = podmanTest.Podman(localRunString) - session.WaitWithDefaultTimeout() - Expect(session).Should(Exit(0)) - containerID2 := session.OutputToString() - - // Checkpoint first container - result := podmanTest.Podman([]string{"container", "checkpoint", "--create-image", checkpointImage1, "--keep", containerID1}) - result.WaitWithDefaultTimeout() - Expect(result).Should(Exit(0)) - Expect(podmanTest.NumberOfContainersRunning()).To(Equal(1)) - - // Checkpoint second container - result = podmanTest.Podman([]string{"container", "checkpoint", "--create-image", checkpointImage2, "--keep", containerID2}) - result.WaitWithDefaultTimeout() - Expect(result).Should(Exit(0)) - Expect(podmanTest.NumberOfContainersRunning()).To(Equal(0)) - - // Remove existing containers - result = podmanTest.Podman([]string{"rm", "-t", "1", "-f", containerName1, containerName2}) - result.WaitWithDefaultTimeout() - Expect(result).Should(Exit(0)) - - // Restore both containers from images - result = podmanTest.Podman([]string{"container", "restore", checkpointImage1, checkpointImage2}) - result.WaitWithDefaultTimeout() - Expect(result).Should(Exit(0)) - Expect(podmanTest.NumberOfContainersRunning()).To(Equal(2)) - - // Check if first container is running - status := podmanTest.Podman([]string{"inspect", containerName1, "--format={{.State.Status}}"}) - status.WaitWithDefaultTimeout() - Expect(status).Should(Exit(0)) - Expect(status.OutputToString()).To(Equal("running")) - - // Check if second container is running - status = podmanTest.Podman([]string{"inspect", containerName2, "--format={{.State.Status}}"}) - status.WaitWithDefaultTimeout() - Expect(status).Should(Exit(0)) - Expect(status.OutputToString()).To(Equal("running")) - - // Clean-up - result = podmanTest.Podman([]string{"rm", "-t", "0", "-fa"}) - result.WaitWithDefaultTimeout() - Expect(result).Should(Exit(0)) - Expect(podmanTest.NumberOfContainersRunning()).To(Equal(0)) - - result = podmanTest.Podman([]string{"rmi", checkpointImage1, checkpointImage2}) - result.WaitWithDefaultTimeout() - Expect(result).Should(Exit(0)) - Expect(podmanTest.NumberOfContainersRunning()).To(Equal(0)) - }) - - It("podman run checkpoint image to restore container", func() { - SkipIfContainerized("FIXME: #15015. All checkpoint tests hang when containerized.") - // Container image must be lowercase - checkpointImage := "alpine-checkpoint-" + strings.ToLower(RandomString(6)) - containerName := "alpine-container-" + RandomString(6) - - // Create container - localRunString := []string{"run", "-d", "--name", containerName, ALPINE, "top"} - session := podmanTest.Podman(localRunString) - session.WaitWithDefaultTimeout() - Expect(session).Should(Exit(0)) - containerID1 := session.OutputToString() - - // Checkpoint container, create checkpoint image - result := podmanTest.Podman([]string{"container", "checkpoint", "--create-image", checkpointImage, "--keep", containerID1}) - result.WaitWithDefaultTimeout() - Expect(result).Should(Exit(0)) - Expect(podmanTest.NumberOfContainersRunning()).To(Equal(0)) - - // Remove existing container - result = podmanTest.Podman([]string{"rm", "-t", "1", "-f", containerName}) - result.WaitWithDefaultTimeout() - Expect(result).Should(Exit(0)) - - // Restore containers from image using `podman run` - result = podmanTest.Podman([]string{"run", checkpointImage}) - result.WaitWithDefaultTimeout() - Expect(result).Should(Exit(0)) - Expect(podmanTest.NumberOfContainersRunning()).To(Equal(1)) - - // Check if the container is running - status := podmanTest.Podman([]string{"inspect", containerName, "--format={{.State.Status}}"}) - status.WaitWithDefaultTimeout() - Expect(status).Should(Exit(0)) - Expect(status.OutputToString()).To(Equal("running")) - - // Clean-up - result = podmanTest.Podman([]string{"rm", "-t", "0", "-fa"}) - result.WaitWithDefaultTimeout() - Expect(result).Should(Exit(0)) - Expect(podmanTest.NumberOfContainersRunning()).To(Equal(0)) - - result = podmanTest.Podman([]string{"rmi", checkpointImage}) - result.WaitWithDefaultTimeout() - Expect(result).Should(Exit(0)) - Expect(podmanTest.NumberOfContainersRunning()).To(Equal(0)) - }) -})