From 3f4a73d632bcf4d9da0332a6b26b2c6337423387 Mon Sep 17 00:00:00 2001 From: Akihiro Suda Date: Fri, 15 Dec 2023 10:40:24 +0900 Subject: [PATCH] TestCheckpoint: skip on ErrCriuMissingFeatures Signed-off-by: Akihiro Suda --- libcontainer/criu_linux.go | 12 +++++++----- libcontainer/integration/checkpoint_test.go | 4 ++++ 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/libcontainer/criu_linux.go b/libcontainer/criu_linux.go index 0567152403f..66178fc16f6 100644 --- a/libcontainer/criu_linux.go +++ b/libcontainer/criu_linux.go @@ -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 @@ -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") } } @@ -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 diff --git a/libcontainer/integration/checkpoint_test.go b/libcontainer/integration/checkpoint_test.go index 4783feed0fd..c5426af1983 100644 --- a/libcontainer/integration/checkpoint_test.go +++ b/libcontainer/integration/checkpoint_test.go @@ -3,6 +3,7 @@ package integration import ( "bufio" "bytes" + "errors" "os" "os/exec" "path/filepath" @@ -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) }