From 39ff1c04fef4a66906ccebfafba4ed0ff9b0a85b Mon Sep 17 00:00:00 2001 From: Tonis Tiigi Date: Fri, 3 Feb 2023 14:34:24 -0800 Subject: [PATCH] inline cache: fix blob indexes by uncompressed digest Signed-off-by: Tonis Tiigi --- cache/remotecache/inline/inline.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/cache/remotecache/inline/inline.go b/cache/remotecache/inline/inline.go index 59631a9d5491..036ec059f76e 100644 --- a/cache/remotecache/inline/inline.go +++ b/cache/remotecache/inline/inline.go @@ -56,16 +56,20 @@ func (ce *exporter) ExportForLayers(ctx context.Context, layers []digest.Digest) return nil, err } + layerBlobDigests := make([]digest.Digest, len(layers)) + descs2 := map[digest.Digest]v1.DescriptorProviderPair{} - for _, k := range layers { + for i, k := range layers { if v, ok := descs[k]; ok { descs2[k] = v + layerBlobDigests[i] = k continue } // fallback for uncompressed digests for _, v := range descs { if uc := v.Descriptor.Annotations["containerd.io/uncompressed"]; uc == string(k) { descs2[v.Descriptor.Digest] = v + layerBlobDigests[i] = v.Descriptor.Digest } } } @@ -87,7 +91,7 @@ func (ce *exporter) ExportForLayers(ctx context.Context, layers []digest.Digest) // reorder layers based on the order in the image blobIndexes := make(map[digest.Digest]int, len(layers)) - for i, blob := range layers { + for i, blob := range layerBlobDigests { blobIndexes[blob] = i }