Skip to content

Commit

Permalink
Merge pull request #45678 from thaJeztah/24.0_backport_fix_snapshotte…
Browse files Browse the repository at this point in the history
…r_change

[24.0 backport] Make sure the image is unpacked for the current snapshotter
  • Loading branch information
thaJeztah committed Jun 2, 2023
2 parents 32d442a + 1fc1977 commit 4b3329d
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions daemon/containerd/image_snapshot.go
Expand Up @@ -3,6 +3,7 @@ package containerd
import (
"context"

"github.com/containerd/containerd"
containerdimages "github.com/containerd/containerd/images"
"github.com/containerd/containerd/leases"
"github.com/containerd/containerd/platforms"
Expand All @@ -12,7 +13,7 @@ import (

// PrepareSnapshot prepares a snapshot from a parent image for a container
func (i *ImageService) PrepareSnapshot(ctx context.Context, id string, parentImage string, platform *ocispec.Platform) error {
desc, err := i.resolveDescriptor(ctx, parentImage)
img, err := i.resolveImage(ctx, parentImage)
if err != nil {
return err
}
Expand All @@ -24,7 +25,19 @@ func (i *ImageService) PrepareSnapshot(ctx context.Context, id string, parentIma
matcher = platforms.Only(*platform)
}

desc, err = containerdimages.Config(ctx, cs, desc, matcher)
platformImg := containerd.NewImageWithPlatform(i.client, img, matcher)
unpacked, err := platformImg.IsUnpacked(ctx, i.snapshotter)
if err != nil {
return err
}

if !unpacked {
if err := platformImg.Unpack(ctx, i.snapshotter); err != nil {
return err
}
}

desc, err := containerdimages.Config(ctx, cs, img.Target, matcher)
if err != nil {
return err
}
Expand Down

0 comments on commit 4b3329d

Please sign in to comment.