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

Add FIXMEs about handling of zstd:chunked blob annotations on blob changes #1894

Merged
merged 2 commits into from
Apr 4, 2023

Conversation

mtrmac
Copy link
Collaborator

@mtrmac mtrmac commented Mar 23, 2023

It's completely undefined whether the OCI blob annotations apply to the object as a concept, regardless of representation, or to the specific binary representation. So it's unclear whether we should preserve or drop them when compressing/decompressing/substituting blobs.

In particular, we currently don't truly correctly handle the zstd:chunked annotations on:

  • decompression (should be dropped)
  • recompression (should be dropped)
  • substitution (should be replaced by data about the other blob, if any; we don't record that)

Right now, we drop all annotations on decompression and recompression (which happens to work fine), and preserve annotations on substitution (which is technically invalid).

Luckily, the zstd:chunked use is opportunistic, and if the annotations are invalid or not applicable, the manifest checksum fails, and we fall through to an ordinary pull; so, that is not quite a deal breaker.

So, for now, just add FIXMEs recording the pain points.

To fix this truly correctly, we would need:

  • a new metadataCleaner field in pkg/compression/internal.Algorithm
  • a new pkg/compression.CleanMetadata
  • turning public manifest.Manifest into internal/manifest.Manifest where we can add methods
  • adding internal/manifest.Manifest.LayerInfosWithCompression that turns MIME types into `compression.Algorigthm values
  • (using that in copy.copyLayer instead of the current hard-coded switch)
  • then either defining a new alternative to UpdatedImage that can handle these annotations naturally,
    or all the marked users that need to clean the annotations themselves calling LayerInfosWithCompression
    and CleanMetadata on the affected blobs.
  • recording the zstd annotations in the blob info cache
  • reading those annotations when substituting blobs based on the cache

We should do all that long-term, but that's quite a lot of work to fix a metadata inconsistency which we can currently silently, with moderate cost, hide from the user.


Also includes a fix for some typos discovered when scoping the “correct” fix.

@mtrmac
Copy link
Collaborator Author

mtrmac commented Mar 23, 2023

@giuseppe FYI, to make sure you have the full picture. If this handling is unreasonable, please speak up.

@TomSweeneyRedHat
Copy link
Member

if @giuseppe is hip with these changes, LGTM

@giuseppe
Copy link
Member

It's completely undefined whether the OCI blob annotations apply to the object as a concept, regardless of representation, or to the specific binary representation

in the case of zstd:chunked, they apply to the binary representation.

@mtrmac
Copy link
Collaborator Author

mtrmac commented Mar 28, 2023

Ah, right; that sentence was describing the difficulty for the general copy code.

We will probably, longer-term, end up with a list of per-concept / per-representation annotations…

Signed-off-by: Miloslav Trmač <[email protected]>
…anges

It's completely undefined whether the OCI blob annotations apply to
the object as a concept, regardless of representation, or to the specific
binary representation. So it's unclear whether we should preserve or drop them
when compressing/decompressing/substituting blobs.

In particular, we currently don't truly correctly handle the zstd:chunked
annotations on:
- decompression (should be dropped)
- recompression (should be dropped)
- substitution (should be replaced by data about the other blob, if any; we don't record that)

Right now, we drop all annotations on decompression and recompression (which
happens to work fine), and preserve annotations on substitution (which is technically
invalid).

Luckily, the zstd:chunked use is opportunistic, and if the annotations are invalid
or not applicable, the manifest checksum fails, and we fall through to an ordinary pull;
so, that is not quite a deal breaker.

So, for now, just add FIXMEs recording the pain points.

To fix this truly correctly, we would need:
- a new metadataCleaner field in pkg/compression/internal.Algorithm
- a new pkg/compression.CleanMetadata
- turning public manifest.Manifest into internal/manifest.Manifest where we can add methods
- adding internal/manifest.Manifest.LayerInfosWithCompression that turns MIME types into compression.Algorithm values
- (using that in copy.copyLayer instead of the current hard-coded switch)
- then either defining a new alternative to UpdatedImage that can handle these annotations naturally,
  or all the marked users that need to clean the annotations themselves calling LayerInfosWithCompression
  and CleanMetadata on the affected blobs.
- recording the zstd annotations in the blob info cache
- reading those annotations when substituting blobs based on the cache

We should do all that long-term, but that's quite a lot of work to fix a metadata inconsistency
which we can currently silently, with moderate cost, hide from the user.

Signed-off-by: Miloslav Trmač <[email protected]>
@rhatdan
Copy link
Member

rhatdan commented Apr 3, 2023

@giuseppe waiting on you?

Copy link
Member

@giuseppe giuseppe left a comment

Choose a reason for hiding this comment

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

LGTM

@mtrmac mtrmac merged commit 9ce8277 into containers:main Apr 4, 2023
@mtrmac mtrmac deleted the drop-annotations branch April 4, 2023 18:29
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.

Image Copy looses layer annotations when reusing blob
4 participants