Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[release-5.10] copy: compute blob compression on reused blobs based on source MediaType #1162

Merged
merged 2 commits into from
Feb 25, 2021

Conversation

nalind
Copy link
Member

@nalind nalind commented Feb 24, 2021

Teach BlobInfoCache2 implementations to be able to retrieve the type of compression that was applied to a blob with a given digest, if we know it.

If we successfully reuse a blob while writing an image, and we know how a blob with that reused blob's digest was compressed, use that information when updating the MIME type for the reused blob.

This covers situations where TryReusingBlob() returns a BlobInfo containing a different digest and MIME type than the one we originally asked it to reuse. copy.imageCopier.copyLayers() sets it up as part of the LayerInfos in update info that copy.imageCopier.copyUpdatedConfigAndManifest() passes to src.UpdatedImage(), and the UpdateLayerInfos() implementations discard the MIME type from the new BlobInfo in favor of the MIME type in the original layers list.

The buildah blob cache triggers this case when we use it while pushing an image where the local copy of the manifest specifies an uncompressed digest and MIME type, and the blob cache tries to substitute the digest of the compressed version in LayerInfosForCopy(), since it knows it can retrieve the compressed version from its cache. The blob cache doesn't get used very often, so we've only recently started noticing it since we started testing #1089 in openshift/origin#25830.

Cherry picked from #1138.

When copying a compressed blob without making any modifications to it,
set the CompressionFormat in the returned BlobInfo to reflect the
compression algorithm that was used to compress the blob.

Signed-off-by: Nalin Dahyabhai <[email protected]>
When copying blobs, if we end up reusing a blob from the destination
with the same digest as that given in the srcInfo, but don't know how
that reused blob was compressed, compute the compression information
from the MediaType included in the srcInfo, if one was supplied.

Signed-off-by: Nalin Dahyabhai <[email protected]>
Copy link
Member

@vrothberg vrothberg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@vrothberg vrothberg merged commit 991fe96 into containers:release-5.10 Feb 25, 2021
@vrothberg
Copy link
Member

I'll cut a new release in a jiffy.

@nalind nalind deleted the blobinfocache2-reuse-5.10 branch February 25, 2021 13:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants