From 046a8412f85cda88f67003313a8f7938a63fca90 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miloslav=20Trma=C4=8D?= Date: Wed, 31 Jan 2024 20:07:45 +0100 Subject: [PATCH] Ensure uncompressed layers from c/storage are recorded as uncompressed on upload MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When copying an uncompressed layer without modification, arrange types.BlobInfo.CompressionOperation to be set to types.Decompress, so that we edit the manifest to use an uncompressed MIME type (and not, e.g. a zstd:chunked MIME type which might not be representable in the destination at all). This is all still gated by the > if srcInfosUpdated || layerDigestsDiffer(srcInfos, destInfos) { condition in copyLayers, so we don't do these manifest updates frivolously. Signed-off-by: Miloslav Trmač --- copy/compression.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/copy/compression.go b/copy/compression.go index b602ad56af..5eca99235e 100644 --- a/copy/compression.go +++ b/copy/compression.go @@ -250,21 +250,25 @@ func (ic *imageCopier) bpcPreserveOriginal(_ *sourceStream, detected bpDetectCom // so that src.UpdatedImage() doesn’t fail; assume that for such blobs // LayerInfosForCopy() should not be making any changes in the first place. var bpcOp bpcOperation + var uploadedOp types.LayerCompression var algorithm *compressiontypes.Algorithm switch { case !layerCompressionChangeSupported: bpcOp = bpcOpPreserveOpaque + uploadedOp = types.PreserveOriginal algorithm = nil case detected.isCompressed: bpcOp = bpcOpPreserveCompressed + uploadedOp = types.PreserveOriginal algorithm = &detected.format default: bpcOp = bpcOpPreserveUncompressed + uploadedOp = types.Decompress algorithm = nil } return &bpCompressionStepData{ operation: bpcOp, - uploadedOperation: types.PreserveOriginal, + uploadedOperation: uploadedOp, uploadedAlgorithm: algorithm, srcCompressorName: detected.srcCompressorName, uploadedCompressorName: detected.srcCompressorName,