Skip to content

Commit

Permalink
Merge pull request containers#12184 from adrianreber/2021-11-05-stats…
Browse files Browse the repository at this point in the history
…-dump

Add 'stats-dump' file to exported checkpoint
  • Loading branch information
openshift-merge-robot authored Nov 8, 2021
2 parents abbd6c1 + 3e1940a commit 865653b
Show file tree
Hide file tree
Showing 9 changed files with 636 additions and 3 deletions.
8 changes: 5 additions & 3 deletions libpod/container_internal_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
"time"

metadata "github.com/checkpoint-restore/checkpointctl/lib"
"github.com/checkpoint-restore/go-criu/v5/stats"
cdi "github.com/container-orchestrated-devices/container-device-interface/pkg"
"github.com/containernetworking/plugins/pkg/ns"
"github.com/containers/buildah/pkg/chrootuser"
Expand Down Expand Up @@ -1013,6 +1014,7 @@ func (c *Container) exportCheckpoint(options ContainerCheckpointOptions) error {
metadata.ConfigDumpFile,
metadata.SpecDumpFile,
metadata.NetworkStatusFile,
stats.StatsDump,
}

if c.LogDriver() == define.KubernetesLogging ||
Expand Down Expand Up @@ -1197,7 +1199,7 @@ func (c *Container) checkpoint(ctx context.Context, options ContainerCheckpointO
if !options.Keep && !options.PreCheckPoint {
cleanup := []string{
"dump.log",
"stats-dump",
stats.StatsDump,
metadata.ConfigDumpFile,
metadata.SpecDumpFile,
}
Expand Down Expand Up @@ -1564,8 +1566,8 @@ func (c *Container) restore(ctx context.Context, options ContainerCheckpointOpti
cleanup := [...]string{
"restore.log",
"dump.log",
"stats-dump",
"stats-restore",
stats.StatsDump,
stats.StatsRestore,
metadata.NetworkStatusFile,
metadata.RootFsDiffTar,
metadata.DeletedFilesFile,
Expand Down
2 changes: 2 additions & 0 deletions pkg/checkpoint/checkpoint_restore.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"os"

metadata "github.com/checkpoint-restore/checkpointctl/lib"
"github.com/checkpoint-restore/go-criu/v5/stats"
"github.com/containers/common/libimage"
"github.com/containers/common/pkg/config"
"github.com/containers/podman/v3/libpod"
Expand Down Expand Up @@ -39,6 +40,7 @@ func CRImportCheckpoint(ctx context.Context, runtime *libpod.Runtime, restoreOpt
"volumes",
"ctr.log",
"artifacts",
stats.StatsDump,
metadata.RootFsDiffTar,
metadata.DeletedFilesFile,
metadata.NetworkStatusFile,
Expand Down
53 changes: 53 additions & 0 deletions test/e2e/checkpoint_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@ import (
"net"
"os"
"os/exec"
"path/filepath"
"strings"
"time"

"github.com/checkpoint-restore/go-criu/v5/stats"
"github.com/containers/podman/v3/pkg/checkpoint/crutils"
"github.com/containers/podman/v3/pkg/criu"
. "github.com/containers/podman/v3/test/utils"
Expand Down Expand Up @@ -1191,4 +1193,55 @@ var _ = Describe("Podman checkpoint", func() {
// Remove exported checkpoint
os.Remove(fileName)
})

It("podman checkpoint container with export and statistics", func() {
localRunString := getRunString([]string{
"--rm",
ALPINE,
"top",
})
session := podmanTest.Podman(localRunString)
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(podmanTest.NumberOfContainersRunning()).To(Equal(1))
cid := session.OutputToString()
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).Should(Exit(0))
Expect(podmanTest.NumberOfContainersRunning()).To(Equal(0))
Expect(podmanTest.NumberOfContainers()).To(Equal(0))

// Extract checkpoint archive
destinationDirectory, err := CreateTempDirInTempDir()
Expect(err).ShouldNot(HaveOccurred())

tarsession := SystemExec(
"tar",
[]string{
"xf",
fileName,
"-C",
destinationDirectory,
},
)
Expect(tarsession).Should(Exit(0))

_, err = os.Stat(filepath.Join(destinationDirectory, stats.StatsDump))
Expect(err).ShouldNot(HaveOccurred())

Expect(os.RemoveAll(destinationDirectory)).To(BeNil())

// Remove exported checkpoint
os.Remove(fileName)
})
})

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 865653b

Please sign in to comment.