Return correct error if CRIU binary is missing

For the first version of containerd's "Forensic Container Checkpointing"
support the error message if the CRIU binary is not found was
deliberately wrong to not break Kubernetes e2e_node tests.

Now that the e2e_node tests have been adapted, containerd can return the
correct error message.

Signed-off-by: Adrian Reber <areber@redhat.com>
This commit is contained in:
Adrian Reber 2024-03-12 08:29:30 +00:00
parent 9fc0b64bc4
commit 218e2cf7cd
No known key found for this signature in database
GPG Key ID: 82C9378ED3C4906A

View File

@ -41,8 +41,6 @@ import (
ptypes "github.com/containerd/containerd/v2/protobuf/types" ptypes "github.com/containerd/containerd/v2/protobuf/types"
"github.com/containerd/log" "github.com/containerd/log"
v1 "github.com/opencontainers/image-spec/specs-go/v1" v1 "github.com/opencontainers/image-spec/specs-go/v1"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
"github.com/containerd/containerd/v2/client" "github.com/containerd/containerd/v2/client"
runtime "k8s.io/cri-api/pkg/apis/runtime/v1" runtime "k8s.io/cri-api/pkg/apis/runtime/v1"
@ -73,8 +71,17 @@ func (c *criService) CheckpointContainer(ctx context.Context, r *runtime.Checkpo
// This is the wrong error message and needs to be adapted once // This is the wrong error message and needs to be adapted once
// Kubernetes (the e2e_node/checkpoint) test has been changed to // Kubernetes (the e2e_node/checkpoint) test has been changed to
// handle too old or missing CRIU error messages. // handle too old or missing CRIU error messages.
log.G(ctx).WithError(err).Errorf("Failed to checkpoint container %q", r.GetContainerId()) errorMessage := fmt.Sprintf(
return nil, status.Errorf(codes.Unimplemented, "method CheckpointContainer not implemented") "CRIU binary not found or too old (<%d). Failed to checkpoint container %q",
podCriuVersion,
r.GetContainerId(),
)
log.G(ctx).WithError(err).Errorf(errorMessage)
return nil, fmt.Errorf(
"%s: %w",
errorMessage,
err,
)
} }
container, err := c.containerStore.Get(r.GetContainerId()) container, err := c.containerStore.Get(r.GetContainerId())