From cf7f4f5cc292fff86c5a920bbe2cb5abf62ff6bc Mon Sep 17 00:00:00 2001 From: Radostin Stoyanov Date: Tue, 24 Jun 2025 17:31:32 +0100 Subject: [PATCH] restore: skip pull for existing base image This patch avoids image pull if the base image is already cached locally by containerd. Fixes: #11901 Signed-off-by: Radostin Stoyanov --- .../cri/server/container_checkpoint_linux.go | 27 ++++++++++++------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/internal/cri/server/container_checkpoint_linux.go b/internal/cri/server/container_checkpoint_linux.go index 0e207d6c66..b54963ae86 100644 --- a/internal/cri/server/container_checkpoint_linux.go +++ b/internal/cri/server/container_checkpoint_linux.go @@ -308,17 +308,26 @@ func (c *criService) CRImportCheckpoint( } } - // Pulling the image the checkpoint is based on. This is a bit different - // than automatic image pulling. The checkpoint image is not automatically - // pulled, but the image the checkpoint is based on. - // During checkpointing the base image of the checkpoint is stored in the - // checkpoint archive as NAME@DIGEST. The checkpoint archive also contains - // the tag with which it was initially pulled. - // First step is to pull NAME@DIGEST - containerdImage, err := c.client.Pull(ctx, config.RootfsImageRef) + var containerdImage client.Image + + containerdImage, err = c.client.GetImage(ctx, config.RootfsImageRef) if err != nil { - return "", fmt.Errorf("failed to pull checkpoint base image %s: %w", config.RootfsImageRef, err) + if !errdefs.IsNotFound(err) { + return "", fmt.Errorf("failed to get checkpoint base image %s: %w", config.RootfsImageRef, err) + } + // Pulling the image the checkpoint is based on. This is a bit different + // than automatic image pulling. The checkpoint image is not automatically + // pulled, but the image the checkpoint is based on. + // During checkpointing the base image of the checkpoint is stored in the + // checkpoint archive as NAME@DIGEST. The checkpoint archive also contains + // the tag with which it was initially pulled. + // First step is to pull NAME@DIGEST + containerdImage, err = c.client.Pull(ctx, config.RootfsImageRef) + if err != nil { + return "", fmt.Errorf("failed to pull checkpoint base image %s: %w", config.RootfsImageRef, err) + } } + if _, err := reference.ParseAnyReference(config.RootfsImageName); err != nil { return "", fmt.Errorf("error parsing reference: %q is not a valid repository/tag %v", config.RootfsImageName, err) }