Skip to content

Commit

Permalink
Fix manifest updates when we match a layer by TOC digest
Browse files Browse the repository at this point in the history
Either return a compressed digest and compressed size, or
an uncompressed digest and an uncompressed size (if we are allowed
to change the manifest); if neither is possible, ignore the match
and force a layer pull.

In almost all cases, a TOC match implies the layer has a TOC digest
annotation, i.e. the input manifest is OCI, where the size field
is mandatory; so this should not change which layers will be reused
- it just changes the returned size value.

Signed-off-by: Miloslav Trmač <[email protected]>
  • Loading branch information
mtrmac committed Feb 14, 2024
1 parent bdfde4d commit 80395a3
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions storage/storage_dest.go
Original file line number Diff line number Diff line change
Expand Up @@ -471,12 +471,21 @@ func (s *storageImageDestination) tryReusingBlobAsPending(blobDigest digest.Dige
return false, private.ReusedBlob{}, fmt.Errorf(`looking for layers with TOC digest %q: %w`, options.TOCDigest, err)
}
if len(layers) > 0 {
s.lockProtected.indexToTOCDigest[*options.LayerIndex] = options.TOCDigest
return true, private.ReusedBlob{
Digest: blobDigest,
Size: layers[0].UncompressedSize,
MatchedByTOCDigest: true,
}, nil
if size != -1 {
s.lockProtected.indexToTOCDigest[*options.LayerIndex] = options.TOCDigest
return true, private.ReusedBlob{
Digest: blobDigest,
Size: size,
MatchedByTOCDigest: true,
}, nil
} else if options.CanSubstitute && layers[0].UncompressedDigest != "" {
s.lockProtected.indexToTOCDigest[*options.LayerIndex] = options.TOCDigest
return true, private.ReusedBlob{
Digest: layers[0].UncompressedDigest,
Size: layers[0].UncompressedSize,
MatchedByTOCDigest: true,
}, nil
}
}
}

Expand Down

0 comments on commit 80395a3

Please sign in to comment.