-
Notifications
You must be signed in to change notification settings - Fork 99
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
mutate: add uncompressed blob size annotation #510
mutate: add uncompressed blob size annotation #510
Conversation
Codecov Report
❗ Your organization needs to install the Codecov GitHub app to enable full functionality. Additional details and impacted files@@ Coverage Diff @@
## main #510 +/- ##
==========================================
- Coverage 73.48% 73.45% -0.03%
==========================================
Files 60 60
Lines 4884 4902 +18
==========================================
+ Hits 3589 3601 +12
- Misses 935 941 +6
Partials 360 360
|
Sometimes it is useful to have a reliable estimate of the space that would be taken up by a layer when it is unpacked. Since gzip's headers are only accurate up to 4GiB, larger layers can not be easily measured without uncompressing them. This commit adds a field to the gzip and zstd compressors to store the bytes read from the stream during compression and uses that to set an annotation on newly generated layers. If the noop compressor is used, the annotation is not added, as the existing "compressed" layer size would be the same. Signed-off-by: Michael McCracken <[email protected]>
96974db
to
8f65e8f
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm... also seems very useful. why did the original spec not have this?
A very very good question which @cyphar also pointed to and we are painfully finding out when inter-operating with other tools :( |
Uh, hm. Ping @tych0 ? Was this meant to be merged? |
I don't see why not, thanks for the ping. |
Sometimes it is useful to have a reliable estimate of the space that would be taken up by a layer when it is unpacked. Since gzip's headers are only accurate up to 4GiB, larger layers can not be easily measured without uncompressing them.
This commit adds a field to the gzip and zstd compressors to store the bytes read from the stream during compression and uses that to set an annotation on newly generated layers.
If the noop compressor is used, the annotation is not added, as the existing "compressed" layer size would be the same.
👀 note that the annotation name is just a shot in the dark, I am open to suggestions for something that'd make more sense.
For validation, I unpacked the
opensuse/leap:15.4
image withsudo ~/umoci/umoci unpack --image opensuse:latest opensuse-latest
added a 5GiB file with just
truncate -s 5GB opensuse-latest/rootfs/test
then repacked and inspected the resulting blob:
sudo ~/umoci/umoci --log=debug repack --image ./opensuse:latest-repacked-w-bigchange opensuse-latest/
here are the layers from the resulting image:
and we can see the incorrect gzip header, followed by the actual size after decompressing:
(note I copied the blobs from the layout into this tmp dir, this is slightly edited)