Skip to content

Respect compression_format from containers.conf in push, build --cache-to, and commit#6757

Open
Honny1 wants to merge 5 commits intocontainers:mainfrom
Honny1:teach-Zstd
Open

Respect compression_format from containers.conf in push, build --cache-to, and commit#6757
Honny1 wants to merge 5 commits intocontainers:mainfrom
Honny1:teach-Zstd

Conversation

@Honny1
Copy link
Copy Markdown
Member

@Honny1 Honny1 commented Apr 1, 2026

  • buildah push now falls back to compression_format and compression_level from containers.conf when --compression-format is not set
  • buildah build --cache-to passes CompressionFormat/ForceCompressionFormat to cache push, so cached layers use the configured compression instead of defaulting to gzip
  • buildah build gains --cache-compression-format, --cache-compression-level, and --cache-force-compression flags for controlling cache layer compression independently
  • buildah commit gains --compression-format, --compression-level, and --force-compression flags with containers.conf fallback
  • Fix commit.go switch to set DirForceCompress for all compression algorithms, not just gzip
  • Fix push.go blobcache to treat any non-uncompressed format as requiring compression
  • Add conflicting flag validation for --disable-compression with --compression-format/--force-compression

Fixes: #6660
Fixes: #6072

Depends on: containers/container-libs#731

What type of PR is this?

/kind api-change

/kind bug

/kind cleanup

/kind deprecation
/kind design
/kind documentation
/kind failing-test
/kind feature
/kind flake
/kind other

What this PR does / why we need it:

How to verify it

Which issue(s) this PR fixes:

Special notes for your reviewer:

Does this PR introduce a user-facing change?

`push`, build`, `commit`: respect `compression_format` from `containers.conf`

`buildah push`, `buildah build --cache-to`, and `buildah commit` now honor the `compression_format` and `compression_level` settings from `containers.conf`. Previously, `--cache-to` ignored these settings and always used `gzip`, causing cache layers to lose the configured compression. `buildah build` also gains new `--cache-compression-format`, `--cache-compression-level`, and `--cache-force-compression` flags for controlling cache layer compression independently of the final image. `buildah commit` also gains new `--compression-format`, `--compression-level`, and `--force-compression` flags.

@Honny1
Copy link
Copy Markdown
Member Author

Honny1 commented Apr 1, 2026

While fixing the build cache, I decided to also check the pull and commit where compression is used.

@Honny1 Honny1 closed this Apr 1, 2026
@Honny1 Honny1 reopened this Apr 1, 2026
@Honny1 Honny1 force-pushed the teach-Zstd branch 7 times, most recently from 4ce00cc to b66921a Compare April 17, 2026 09:14
@packit-as-a-service
Copy link
Copy Markdown

Ephemeral COPR build failed. @containers/packit-build please check.

@Honny1 Honny1 marked this pull request as ready for review April 17, 2026 10:11
@dosubot dosubot Bot added the size:L This PR changes 100-499 lines, ignoring generated files. label Apr 17, 2026
@Honny1
Copy link
Copy Markdown
Member Author

Honny1 commented Apr 17, 2026

/packit rebuild-failed

@Honny1
Copy link
Copy Markdown
Member Author

Honny1 commented Apr 17, 2026

PTAL @containers/buildah-maintainers

Comment thread pkg/cli/build.go Outdated
Comment on lines +254 to +256
if defaultContainerConfig.Engine.CompressionLevel != nil {
compressionLevel = defaultContainerConfig.Engine.CompressionLevel
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Suggested change
if defaultContainerConfig.Engine.CompressionLevel != nil {
compressionLevel = defaultContainerConfig.Engine.CompressionLevel
}
compressionLevel = defaultContainerConfig.Engine.CompressionLevel

Definitely non-blocking, it just caught my eye, but the if is redundant, right? compressionLevel would be nil on declaration, so assigning nil to it again would not be a problem.

@simonbrauner
Copy link
Copy Markdown

LGTM

Copy link
Copy Markdown
Member

@nalind nalind left a comment

Choose a reason for hiding this comment

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

What's the intent behind not adding to "build" the flags that are being added to "push" and "commit"?

Comment thread cmd/buildah/commit.go
if err != nil {
return err
}
options.CompressionFormat = &algo
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Was the bit that checks for c.Flag("compression-format").Changed above intended to be merged into this block, to parallel the similar logic in the next block?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Ah, that is much cleaner. I will fix that.

Comment thread cmd/buildah/push.go
if err != nil {
return err
}
options.CompressionFormat = &algo
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Was the bit that checks for c.Flag("compression-format").Changed above intended to be merged into this block, to parallel the similar logic in the next block?

Honny1 added 3 commits April 24, 2026 10:05
Signed-off-by: Jan Rodák <hony.com@seznam.cz>
Fixes: containers#6660
Fixes: containers#6072

Signed-off-by: Jan Rodák <hony.com@seznam.cz>
Signed-off-by: Jan Rodák <hony.com@seznam.cz>
@Honny1
Copy link
Copy Markdown
Member Author

Honny1 commented Apr 24, 2026

What's the intent behind not adding to "build" the flags that are being added to "push" and "commit"?

I forgot to do that. Good catch.

Signed-off-by: Jan Rodák <hony.com@seznam.cz>
@dosubot dosubot Bot added size:XL This PR changes 500-999 lines, ignoring generated files. and removed size:L This PR changes 100-499 lines, ignoring generated files. labels Apr 24, 2026
@Honny1 Honny1 requested a review from nalind April 24, 2026 12:57
Signed-off-by: Jan Rodák <hony.com@seznam.cz>
@Honny1
Copy link
Copy Markdown
Member Author

Honny1 commented Apr 24, 2026

@nalind I addressed your comments.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:XL This PR changes 500-999 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

--cache-to causes compression_format from containers.conf to be ignored cache compression algorithm

3 participants