@@ -160,14 +160,6 @@ func (c *criService) PullImage(ctx context.Context, r *runtime.PullImageRequest)
160160
161161 labels := c .getLabels (ctx , ref )
162162
163- // if snapshotter is devbox, add the pinned image label
164- if snapshotter == "devbox" {
165- if labels == nil {
166- labels = map [string ]string {}
167- }
168- labels [crilabels .PinnedImageLabelKey ] = crilabels .PinnedImageLabelValue
169- }
170-
171163 pullOpts := []containerd.RemoteOpt {
172164 containerd .WithSchema1Conversion , //nolint:staticcheck // Ignore SA1019. Need to keep deprecated package for compatibility.
173165 containerd .WithResolver (resolver ),
@@ -209,11 +201,28 @@ func (c *criService) PullImage(ctx context.Context, r *runtime.PullImageRequest)
209201 imageID := configDesc .Digest .String ()
210202
211203 repoDigest , repoTag := getRepoDigestAndTag (namedRef , image .Target ().Digest , isSchema1 )
204+
205+ // Iterate over imageID, repoTag, and repoDigest
212206 for _ , r := range []string {imageID , repoTag , repoDigest } {
213207 if r == "" {
214208 continue
215209 }
216- if err := c .createImageReference (ctx , r , image .Target (), labels ); err != nil {
210+
211+ // Create a copy of labels for each reference to avoid modifying the original map
212+ var imageLabels map [string ]string
213+ if r == repoTag && snapshotter == DevboxSnapshotter {
214+ // Only add pin label for repoTag when snapshotter is devbox
215+ imageLabels = make (map [string ]string )
216+ for k , v := range labels {
217+ imageLabels [k ] = v
218+ }
219+ imageLabels [crilabels .PinnedImageLabelKey ] = crilabels .PinnedImageLabelValue
220+ } else {
221+ // For imageID and repoDigest, use labels as-is (no pin label)
222+ imageLabels = labels
223+ }
224+
225+ if err := c .createImageReference (ctx , r , image .Target (), imageLabels ); err != nil {
217226 return nil , fmt .Errorf ("failed to create image reference %q: %w" , r , err )
218227 }
219228 // Update image store to reflect the newest state in containerd.
0 commit comments