-
Notifications
You must be signed in to change notification settings - Fork 101
fix(compress): allow passing in compressor options #509
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
Conversation
An alternative approach to: #508 |
https://github.com/project-stacker/stacker/blob/main/pkg/overlay/pack.go#L411C4-L411C4
|
Goals of this PR: 1. Allow passing in options to individual compressor 2. Do not change default behavior Signed-off-by: Ramkumar Chinchani <[email protected]>
Codecov Report
❗ Your organization needs to install the Codecov GitHub app to enable full functionality. Additional details and impacted files@@ Coverage Diff @@
## main #509 +/- ##
==========================================
- Coverage 73.48% 73.45% -0.04%
==========================================
Files 60 60
Lines 4884 4893 +9
==========================================
+ Hits 3589 3594 +5
- Misses 935 939 +4
Partials 360 360
|
Looks nice |
@cyphar thoughts on this PR? Hoping to avoid a umoci fork. |
A fork definitely won't be necessary, I'll review this on Monday. Sorry, I was a bit busy last week. |
@@ -76,6 +91,15 @@ func (gz gzipCompressor) MediaTypeSuffix() string { | |||
return "gzip" | |||
} | |||
|
|||
func (gz gzipCompressor) WithOpt(opt CompressorOpt) Compressor { | |||
switch val := opt.(type) { |
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.
I'm not sure I like that we ignore invalid arguments here. If we make this act on *gzipCompressor
we could make it return a bool (or error) and then the caller can decide if they care about whether WithOpt
actually did anything.
Alternatively, it feels like it should be possible to reimplement all of this compressor stuff with a closure that is passed by the caller (that creates the writer and configures it). But that would require more work...
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.
Maybe we could add a CustomCompressor
just for cases where you need to configure the compression? Idk...
Another place of relevance in umoci code wrt compressor options :( https://github.com/opencontainers/umoci/blob/main/pkg/system/copy.go#L32 |
fyi, filed this against image-spec opencontainers/image-spec#1145 |
@cyphar stacker is using this, yes, and AFAIK it is because a user specifically need it. @mikemccracken can you confirm whether the ability to specify the compression options are still needed? |
stacker has this commit in its stale fork of umoci, yes.
For background, here is my summary of how this became necessary, lightly edited from an internal note in 2023:
other tools like the containers/image library also match the docker compression option, so they don't have this problem. I believe that the people who were using Q: Would it make sense to just hardcode in umoci the same compression block size as docker and containers/image use? |
So, ideally we wouldn't change the current default because doing so would cause the same unfortunate cache busting. However, if Docker really does break our layers then maybe we should just hard-code it... (It is possible to make the new algorithm setup configurable but it's probably not worth the effort unless there's a strong need for it.) |
I don't follow what you mean by cache busting here - AFAIK the only reason this parameter ever comes up is that docker recompresses base tarballs using its own hardcoded blocksize and expects to get the same bits. Are there other tools also doing this?
As for configurability, stacker only needs to match docker, if umoci's default is the same as stacker then we don't need configurability here. |
I meant that if we change the umoci settings then umoci will generate different blobs (with different hashes) compared to previous versions for the same inputs. In practice, OCI images are not built in a fully reproducible way already, but intentionally breaking this is something I try to avoid as much as possible to avoid breaking the caches of layers built with old umoci versions (we have tests to verify we don't do it by accident). But yeah, if Docker is already forcefully doing this to umoci blobs you import today, then changing it to match is not as big of a deal. |
This allows us to switch away from our umoci fork now that upstream supports OverlayfsRootfs and the various features we need. The key changes that allow us to switch away from our fork are: * opencontainers/umoci#572 which implemented a large number of fixes to overlayfs handling, such as opaque whiteouts and several features not implemented in our fork (xattr escaping, handling of missing parent directories, improved rootless support, handling of nested whiteouts inside an opaque whiteout). * opencontainers/umoci#581 which switched to a Docker-friendly gzip block size by default, removing the need to configure it (as suggested in opencontainers/umoci#509). * opencontainers/umoci#587 which implemented full configurable userxattr (user.overlay.*) support. Signed-off-by: Aleksa Sarai <[email protected]>
* feat: update to skopeo v1.13.0 We need to update skopeo to match the pgzip version between skopeo and umoci. Signed-off-by: Aleksa Sarai <[email protected]> * feat: update to github.com/opencontainers/[email protected] This allows us to switch away from our umoci fork now that upstream supports OverlayfsRootfs and the various features we need. The key changes that allow us to switch away from our fork are: * opencontainers/umoci#572 which implemented a large number of fixes to overlayfs handling, such as opaque whiteouts and several features not implemented in our fork (xattr escaping, handling of missing parent directories, improved rootless support, handling of nested whiteouts inside an opaque whiteout). * opencontainers/umoci#581 which switched to a Docker-friendly gzip block size by default, removing the need to configure it (as suggested in opencontainers/umoci#509). * opencontainers/umoci#587 which implemented full configurable userxattr (user.overlay.*) support. Signed-off-by: Aleksa Sarai <[email protected]> --------- Signed-off-by: Aleksa Sarai <[email protected]>
Goals of this PR: