From 72db3f52f1c90ea17971e7ee95a47ffd538a4f9b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miloslav=20Trma=C4=8D?= Date: Tue, 30 Apr 2024 19:29:34 +0200 Subject: [PATCH] Use the uncompressed digest we got from a BlobInfoCache for chunked layers MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Rely on it instead of triggering the "untrusted DiffID" logic - Also propagate it to storage Signed-off-by: Miloslav Trmač --- storage/storage_dest.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/storage/storage_dest.go b/storage/storage_dest.go index cce5611432..d6fd4e5fff 100644 --- a/storage/storage_dest.go +++ b/storage/storage_dest.go @@ -889,6 +889,16 @@ func (s *storageImageDestination) createNewLayer(index int, layerDigest digest.D diffOutput, ok := s.lockProtected.diffOutputs[index] s.lock.Unlock() if ok { + // If we know a trusted DiffID value (e.g. from a BlobInfoCache), set it in diffOutput. + // That way it will be persisted in storage even if the cache is deleted; also + // we can use the value below to avoid the untrustedUncompressedDigest logic (and notably + // the costly commit delay until a manifest is available). + s.lock.Lock() + if d, ok := s.lockProtected.indexToDiffID[index]; ok { + diffOutput.UncompressedDigest = d + } + s.lock.Unlock() + var untrustedUncompressedDigest digest.Digest if diffOutput.UncompressedDigest == "" { d, err := s.untrustedLayerDiffID(index)