containerd repository: /data/pruva/project-cache/9e790cda-4e27-4fc2-9ed7-a2678dd1691a/repo 116b799b27bcb69462e26db2d70c4823211befeb bafc09e8fb5c3d754f57a77cd0b1fc6b7919834d --- vulnerable v2.2.2 tagImage block --- var containerdImage client.Image containerdImage, err = c.client.GetImage(ctx, config.RootfsImageRef) if err != nil { 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) } tagImage, err := c.client.ImageService().Get(ctx, config.RootfsImageRef) if err != nil { return "", fmt.Errorf("failed to get checkpoint base image %s: %w", config.RootfsImageRef, err) } // Second step is to tag the image with the same tag it used to have // during checkpointing. For the error that the image NAME:TAG already // exists is ignored. It could happen that NAME:TAG now belongs to // another NAME@DIGEST than during checkpointing and the restore will // happen on another image. // TODO: handle if NAME:TAG points to a different NAME@DIGEST tagImage.Name = config.RootfsImageName _, err = c.client.ImageService().Create(ctx, tagImage) if err != nil { if !errdefs.IsAlreadyExists(err) { return "", fmt.Errorf("failed to tag checkpoint base image %s with %s: %w", config.RootfsImageRef, config.RootfsImageName, err) } } var image imagestore.Image --- fixed v2.2.5 corresponding block (tag creation removed) --- 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) } var image imagestore.Image for i := 1; i < 500; i++ { // This is probably wrong. Not sure how to wait for an image to appear in // the image (or content) store. log.G(ctx).Debugf("Trying to resolve %s:%d", containerdImage.Name(), i) image, err = c.LocalResolve(containerdImage.Name())