Skip to content

Conversation

@nalind
Copy link
Member

@nalind nalind commented Jan 31, 2017

When reapplying a blob to an image that's being written to the storage transport, don't enforce that the digest of the reapplied blob matches the blobinfo's digest, if there is one, because compression makes the reapply method (where we reextract the layer, and if it was originally compressed, recompress it) produce data with the same actual content, but with a different compressed digest.

This should fix cri-o/cri-o#351.

@mtrmac
Copy link
Collaborator

mtrmac commented Feb 1, 2017

This makes sense in isolation, but we need to figure out how this relates to copy.imageCopier.canModifyManifest (i.e. this would break signatures). It might be possible to (from the user’s POV randomly) fail the copy if ReapplyBlob returns a changed digest and we can’t deal with it, or to skip ReapplyBlob and upload the full blob anyway if !canModifyManifest).

Actually storageImage{Source,Destination} are already maintaining an indirection mapping in Layers, from ddigest.Digest to a layer ID; wouldn’t it be equally possible to just add another mapping from the original digest to a new layer ID, or something like that?

(None of this fixes the difficulty that, IIRC, GetBlob(someDigest) may return a compressed blob with an entirely different digest, to be sure, but that’s somewhat independent. Separately, we have #193, where we have similar difficulties (the DiffID of the uncompressed data is known but the digest of the compressed data is not) and have ended up decompressing all blobs in GetBlob. Perhaps there is something common to the two issues?)

@nalind
Copy link
Member Author

nalind commented Feb 1, 2017

Not sure I follow - ReapplyBlob is only called after HasBlob has returned true, and that only happens when we have a digest specified for the blob. (We know this because HasBlob rejects empty values.) For those cases PutBlob's Layers map is already going to be mapping from the specified digests to the corresponding layer IDs.

@mtrmac
Copy link
Collaborator

mtrmac commented Feb 2, 2017

I’m sorry, I was being stupid; PutBlob/putBlob returns the input digest if it is non-empty, not the recomputed hash. So ReapplyBlob always returns the input BlobInfo.Digest unchanged, and there are no manifest update / signature breakage concerns.

Though, if we are recompressing, it’s not only the digest of the compressed data that change, but the size as well, isn’t it? If so, then the blobInfo.Size check should also be conditional on (some renaming of) enforceDigest.

@nalind
Copy link
Member Author

nalind commented Feb 2, 2017

I would have thought it would, but so far I haven't run into that. But you're right, it would make sense to either have ReapplyBlob() set the size to -1 in the blobinfo that it passes to putBlob(), or as you said, make the size check conditional on the same flag, or both. Do you have a strong preference?

@nalind
Copy link
Member Author

nalind commented Feb 2, 2017

... and if the size we compute is different from an expected value that was passed in, should putBlob be returning that size instead?

@mtrmac
Copy link
Collaborator

mtrmac commented Feb 2, 2017

We still need ReapplyBlob to return the original data unmodified so that the manifest and the layer data match, and signatures are not broken. So, that seems to mean that putBlob should receive the expected size, not -1, and return it unmodified

@nalind
Copy link
Member Author

nalind commented Feb 2, 2017

Makes sense. I'll make the changes.

When reapplying a blob to an image that's being written to the storage
transport, don't enforce that the digest and size of the reapplied blob
match the blobinfo's values, if they were provided, because compression
makes the reapply method (where we reextract the layer, and if it was
originally compressed, recompress it) produce data with the same actual
content, but with a different compressed bitstream.

Like we were previously doing for digest values from the blobinfo, make
sure that we return the passed-in blob size if one was specified, else
return the value we computed.

Signed-off-by: Nalin Dahyabhai <[email protected]>
@nalind nalind force-pushed the reapply-without-digest branch from d919f9e to 19869fa Compare February 2, 2017 18:30
@nalind
Copy link
Member Author

nalind commented Feb 2, 2017

Patch updated.

@mtrmac
Copy link
Collaborator

mtrmac commented Feb 2, 2017

👍 pending tests.

Approved with PullApprove

@runcom
Copy link
Member

runcom commented Feb 2, 2017

👍

Approved with PullApprove

@runcom runcom merged commit 1c202c5 into containers:master Feb 2, 2017
@nalind nalind deleted the reapply-without-digest branch December 14, 2017 23:03
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.

Failing image tests

3 participants