mirror of
https://github.com/containers/podman.git
synced 2025-06-22 18:08:11 +08:00
Merge pull request #18857 from Luap99/criu-version-error
criu: return error when checking for min version
This commit is contained in:
@ -1135,8 +1135,8 @@ func (c *Container) exportCheckpoint(options ContainerCheckpointOptions) error {
|
||||
}
|
||||
|
||||
func (c *Container) checkpointRestoreSupported(version int) error {
|
||||
if !criu.CheckForCriu(version) {
|
||||
return fmt.Errorf("checkpoint/restore requires at least CRIU %d", version)
|
||||
if err := criu.CheckForCriu(version); err != nil {
|
||||
return err
|
||||
}
|
||||
if !c.ociRuntime.SupportsCheckpoint() {
|
||||
return errors.New("configured runtime does not support checkpoint/restore")
|
||||
|
@ -93,8 +93,8 @@ func CRImportCheckpoint(ctx context.Context, runtime *libpod.Runtime, restoreOpt
|
||||
|
||||
if restoreOptions.Pod != "" {
|
||||
// Restoring into a Pod requires much newer versions of CRIU
|
||||
if !criu.CheckForCriu(criu.PodCriuVersion) {
|
||||
return nil, fmt.Errorf("restoring containers into pods requires at least CRIU %d", criu.PodCriuVersion)
|
||||
if err := criu.CheckForCriu(criu.PodCriuVersion); err != nil {
|
||||
return nil, fmt.Errorf("restoring containers into pod: %w", err)
|
||||
}
|
||||
// The runtime also has to support it
|
||||
if !crutils.CRRuntimeSupportsPodCheckpointRestore(runtime.GetOCIRuntimePath()) {
|
||||
|
@ -4,6 +4,8 @@
|
||||
package criu
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/checkpoint-restore/go-criu/v6"
|
||||
"github.com/checkpoint-restore/go-criu/v6/rpc"
|
||||
|
||||
@ -12,13 +14,17 @@ import (
|
||||
|
||||
// CheckForCriu uses CRIU's go bindings to check if the CRIU
|
||||
// binary exists and if it at least the version Podman needs.
|
||||
func CheckForCriu(version int) bool {
|
||||
func CheckForCriu(version int) error {
|
||||
c := criu.MakeCriu()
|
||||
result, err := c.IsCriuAtLeast(version)
|
||||
criuVersion, err := c.GetCriuVersion()
|
||||
if err != nil {
|
||||
return false
|
||||
return fmt.Errorf("failed to check for criu version: %w", err)
|
||||
}
|
||||
return result
|
||||
|
||||
if criuVersion >= version {
|
||||
return nil
|
||||
}
|
||||
return fmt.Errorf("checkpoint/restore requires at least CRIU %d, current version is %d", version, criuVersion)
|
||||
}
|
||||
|
||||
func MemTrack() bool {
|
||||
|
@ -3,8 +3,10 @@
|
||||
|
||||
package criu
|
||||
|
||||
func CheckForCriu(version int) bool {
|
||||
return false
|
||||
import "fmt"
|
||||
|
||||
func CheckForCriu(version int) error {
|
||||
return fmt.Errorf("CheckForCriu not supported on this platform")
|
||||
}
|
||||
|
||||
func MemTrack() bool {
|
||||
|
@ -1,6 +1,7 @@
|
||||
package integration
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os/exec"
|
||||
"strconv"
|
||||
"strings"
|
||||
@ -27,8 +28,8 @@ var _ = Describe("Podman checkpoint", func() {
|
||||
Skip("OCI runtime does not support checkpoint/restore")
|
||||
}
|
||||
|
||||
if !criu.CheckForCriu(criu.MinCriuVersion) {
|
||||
Skip("CRIU is missing or too old.")
|
||||
if err := criu.CheckForCriu(criu.MinCriuVersion); err != nil {
|
||||
Skip(fmt.Sprintf("check CRIU version error: %v", err))
|
||||
}
|
||||
})
|
||||
|
||||
|
@ -43,8 +43,8 @@ var _ = Describe("Podman checkpoint", func() {
|
||||
Skip("OCI runtime does not support checkpoint/restore")
|
||||
}
|
||||
|
||||
if !criu.CheckForCriu(criu.MinCriuVersion) {
|
||||
Skip("CRIU is missing or too old.")
|
||||
if err := criu.CheckForCriu(criu.MinCriuVersion); err != nil {
|
||||
Skip(fmt.Sprintf("check CRIU version error: %v", err))
|
||||
}
|
||||
// Only Fedora 29 and newer has a new enough selinux-policy and
|
||||
// container-selinux package to support CRIU in correctly
|
||||
@ -1121,8 +1121,8 @@ var _ = Describe("Podman checkpoint", func() {
|
||||
share := share // copy into local scope, for use inside function
|
||||
|
||||
It(testName, func() {
|
||||
if !criu.CheckForCriu(criu.PodCriuVersion) {
|
||||
Skip("CRIU is missing or too old.")
|
||||
if err := criu.CheckForCriu(criu.PodCriuVersion); err != nil {
|
||||
Skip(fmt.Sprintf("check CRIU pod version error: %v", err))
|
||||
}
|
||||
if !crutils.CRRuntimeSupportsPodCheckpointRestore(podmanTest.OCIRuntime) {
|
||||
Skip("runtime does not support pod restore: " + podmanTest.OCIRuntime)
|
||||
|
Reference in New Issue
Block a user