mirror of
https://github.com/containerd/containerd.git
synced 2026-06-30 19:58:29 +00:00
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 <rstoyano@redhat.com>
This commit is contained in:
@@ -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)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user