c8d/builder: Don't use diffID as snapshot parent

DiffID is only a digest of the one tar layer and matches the snapshot ID
only for the first layer (DiffID = ChainID).

Instead of generating random ID as a key for rolayer, just use the
snapshot ID of the unpacked image content and use it later as a parent
for creating a new RWLayer.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
This commit is contained in:
Paweł Gronowski 2023-08-25 15:28:28 +02:00
parent 8c7e19c5ff
commit c6bded3475
No known key found for this signature in database
GPG key ID: B85EFCFE26DEF92A

View file

@ -194,11 +194,10 @@ func newROLayerForImage(ctx context.Context, imgDesc *ocispec.Descriptor, i *Ima
return nil, err
}
key := stringid.GenerateRandomID()
parent := identity.ChainID(diffIDs).String()
imageSnapshotID := identity.ChainID(diffIDs).String()
return &rolayer{
key: key,
key: imageSnapshotID,
c: i.client,
snapshotter: i.snapshotter,
diffID: "", // Image RO layer doesn't have a diff.
@ -242,7 +241,7 @@ func (rl *rolayer) NewRWLayer() (builder.RWLayer, error) {
}
key := stringid.GenerateRandomID()
mounts, err := snapshotter.Prepare(ctx, key, rl.diffID.String())
mounts, err := snapshotter.Prepare(ctx, key, rl.key)
if err != nil {
return nil, err
}