Skip to content

Commit

Permalink
Enable pod restore with crun
Browse files Browse the repository at this point in the history
`CRRuntimeSupportsPodCheckpointRestore()` is used to check if the current
container runtime (e.g., runc or crun) can restore a container into an
existing Pod. It does this by processing output message to check if the
`--lsm-mount-context` option is supported.  This option was recently
added to crun [1], however, crun and runc have slightly different output
messages:

```
$ crun restore--lsm-mount-contextt
restore: option '--lsm-mount-context' requires an argument
Try `restore --help' or `restore --usage' for more information.
```

```
$ runc restore --lsm-mount-context
ERRO[0000] flag needs an argument: -lsm-mount-context
```

This patch updates the function to support both runtimes.

[1] containers/crun#1578

Signed-off-by: Radostin Stoyanov <rstoyanov@fedoraproject.org>
  • Loading branch information
rst0git committed Oct 21, 2024
1 parent e4d6fa7 commit 642b61a
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion pkg/checkpoint/crutils/checkpoint_restore_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,18 @@ func CRRuntimeSupportsCheckpointRestore(runtimePath string) bool {
func CRRuntimeSupportsPodCheckpointRestore(runtimePath string) bool {
cmd := exec.Command(runtimePath, "restore", "--lsm-mount-context")
out, _ := cmd.CombinedOutput()
return bytes.Contains(out, []byte("flag needs an argument"))

// check for runc
if bytes.Contains(out, []byte("flag needs an argument")) {
return true
}

// check for crun
if bytes.Contains(out, []byte("requires an argument")) {
return true
}

return false
}

// CRGetRuntimeFromArchive extracts the checkpoint metadata from the
Expand Down

0 comments on commit 642b61a

Please sign in to comment.