Skip to content

Commit

Permalink
merge opencontainers#4146 into opencontainers/runc:main
Browse files Browse the repository at this point in the history
Akihiro Suda (1):
  TestCheckpoint: skip on ErrCriuMissingFeatures

LGTMs: cyphar kolyshkin lifubang
  • Loading branch information
cyphar committed Jan 6, 2024
2 parents ab146f2 + 3f4a73d commit c255024
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
12 changes: 7 additions & 5 deletions libcontainer/criu_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ import (

var criuFeatures *criurpc.CriuFeatures

var ErrCriuMissingFeatures = errors.New("criu is missing features")

func (c *Container) checkCriuFeatures(criuOpts *CriuOpts, rpcOpts *criurpc.CriuOpts, criuFeat *criurpc.CriuFeatures) error {
t := criurpc.CriuReqType_FEATURE_CHECK

Expand All @@ -50,14 +52,14 @@ func (c *Container) checkCriuFeatures(criuOpts *CriuOpts, rpcOpts *criurpc.CriuO
return errors.New("CRIU feature check failed")
}

missingFeatures := false
var missingFeatures []string

// The outer if checks if the fields actually exist
if (criuFeat.MemTrack != nil) &&
(criuFeatures.MemTrack != nil) {
// The inner if checks if they are set to true
if *criuFeat.MemTrack && !*criuFeatures.MemTrack {
missingFeatures = true
missingFeatures = append(missingFeatures, "MemTrack")
logrus.Debugf("CRIU does not support MemTrack")
}
}
Expand All @@ -67,13 +69,13 @@ func (c *Container) checkCriuFeatures(criuOpts *CriuOpts, rpcOpts *criurpc.CriuO
if (criuFeat.LazyPages != nil) &&
(criuFeatures.LazyPages != nil) {
if *criuFeat.LazyPages && !*criuFeatures.LazyPages {
missingFeatures = true
missingFeatures = append(missingFeatures, "LazyPages")
logrus.Debugf("CRIU does not support LazyPages")
}
}

if missingFeatures {
return errors.New("CRIU is missing features")
if len(missingFeatures) != 0 {
return fmt.Errorf("%w: %v", ErrCriuMissingFeatures, missingFeatures)
}

return nil
Expand Down
4 changes: 4 additions & 0 deletions libcontainer/integration/checkpoint_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package integration
import (
"bufio"
"bytes"
"errors"
"os"
"os/exec"
"path/filepath"
Expand Down Expand Up @@ -112,6 +113,9 @@ func testCheckpoint(t *testing.T, userns bool) {

if err := container.Checkpoint(preDumpOpts); err != nil {
showFile(t, preDumpLog)
if errors.Is(err, libcontainer.ErrCriuMissingFeatures) {
t.Skip(err)
}
t.Fatal(err)
}

Expand Down

0 comments on commit c255024

Please sign in to comment.