Fix pre-checkpointing

Unfortunately --pre-checkpointing never worked as intended and recent
changes to runc have shown that it is broken.

To create a pre-checkpoint CRIU expects the paths between the
pre-checkpoints to be a relative path. If having a previous checkpoint
it needs the be referenced like this: --prev-images-dir ../parent

Unfortunately Podman was giving runc (and CRIU) an absolute path.

Unfortunately, again, until March 2021 CRIU silently ignored if
the path was not relative and switch back to normal checkpointing.

This has been now fixed in CRIU and runc and running pre-checkpoint
with the latest runc fails, because runc already sees that the path is
absolute and returns an error.

This commit fixes this by giving runc a relative path.

This commit also fixes a second pre-checkpointing error which was just
recently introduced.

So summarizing: pre-checkpointing never worked correctly because CRIU
ignored wrong parameters and recent changes broke it even more.

Now both errors should be fixed.

[NO TESTS NEEDED]

Signed-off-by: Adrian Reber <areber@redhat.com>
Signed-off-by: Adrian Reber <adrian@lisas.de>
This commit is contained in:
Adrian Reber
2021-06-10 12:27:09 +00:00
committed by Matthew Heon
parent b61701acb3
commit c85b6b3fe1
3 changed files with 10 additions and 4 deletions

View File

@ -41,6 +41,7 @@ const (
// name of the directory holding the artifacts // name of the directory holding the artifacts
artifactsDir = "artifacts" artifactsDir = "artifacts"
execDirPermission = 0755 execDirPermission = 0755
preCheckpointDir = "pre-checkpoint"
) )
// rootFsSize gets the size of the container's root filesystem // rootFsSize gets the size of the container's root filesystem
@ -140,7 +141,7 @@ func (c *Container) CheckpointPath() string {
// PreCheckpointPath returns the path to the directory containing the pre-checkpoint-images // PreCheckpointPath returns the path to the directory containing the pre-checkpoint-images
func (c *Container) PreCheckPointPath() string { func (c *Container) PreCheckPointPath() string {
return filepath.Join(c.bundlePath(), "pre-checkpoint") return filepath.Join(c.bundlePath(), preCheckpointDir)
} }
// AttachSocketPath retrieves the path of the container's attach socket // AttachSocketPath retrieves the path of the container's attach socket

View File

@ -907,14 +907,15 @@ func (c *Container) exportCheckpoint(options ContainerCheckpointOptions) error {
includeFiles := []string{ includeFiles := []string{
"artifacts", "artifacts",
"ctr.log", "ctr.log",
metadata.CheckpointDirectory,
metadata.ConfigDumpFile, metadata.ConfigDumpFile,
metadata.SpecDumpFile, metadata.SpecDumpFile,
metadata.NetworkStatusFile, metadata.NetworkStatusFile,
} }
if options.PreCheckPoint { if options.PreCheckPoint {
includeFiles[0] = "pre-checkpoint" includeFiles = append(includeFiles, preCheckpointDir)
} else {
includeFiles = append(includeFiles, metadata.CheckpointDirectory)
} }
// Get root file-system changes included in the checkpoint archive // Get root file-system changes included in the checkpoint archive
var addToTarFiles []string var addToTarFiles []string

View File

@ -787,7 +787,11 @@ func (r *ConmonOCIRuntime) CheckpointContainer(ctr *Container, options Container
args = append(args, "--pre-dump") args = append(args, "--pre-dump")
} }
if !options.PreCheckPoint && options.WithPrevious { if !options.PreCheckPoint && options.WithPrevious {
args = append(args, "--parent-path", ctr.PreCheckPointPath()) args = append(
args,
"--parent-path",
filepath.Join("..", preCheckpointDir),
)
} }
runtimeDir, err := util.GetRuntimeDir() runtimeDir, err := util.GetRuntimeDir()
if err != nil { if err != nil {