imagebuildah: avoid empty layer in single-layer build path#6699
Open
jlebon wants to merge 1 commit intocontainers:mainfrom
Open
imagebuildah: avoid empty layer in single-layer build path#6699jlebon wants to merge 1 commit intocontainers:mainfrom
jlebon wants to merge 1 commit intocontainers:mainfrom
Conversation
In the single-layer build path (i.e. with `--layers=false`), the final commit always created a layer even when only metadata instructions were executed after `FROM`. Fix this by tracking if any instruction actually created data so we can avoid creating a layer in that case. Noticed this when looking at images passed through chunkah, where one can specify the number of layers N to output; the resulting image would have a total of N+1 layers because it's often the case that you want to add metadata after the `FROM oci-archive:...`. Signed-off-by: Jonathan Lebon <jonathan@jlebon.com> Assisted-by: Claude Opus 4.6
|
Ephemeral COPR build failed. @containers/packit-build please check. |
nalind
approved these changes
Feb 27, 2026
Member
nalind
left a comment
There was a problem hiding this comment.
I vaguely recall OpenShift having a build test that checked how many layers a test build added to its output image compared to the base image; it's why we added the stepRequiresLayer() helper function and started using it where we do in multi-layer builds. I don't think that it was a Layers==false (imageOptimizationPolicy==SkipLayers) case, though, so it's probably not going to be tripped up by this change.
Anyway, LGTM. Thanks!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
In the single-layer build path (i.e. with
--layers=false), the final commit always created a layer even when only metadata instructions were executed afterFROM.Fix this by tracking if any instruction actually created data so we can avoid creating a layer in that case.
Noticed this when looking at images passed through chunkah, where one can specify the number of layers N to output; the resulting image would have a total of N+1 layers because it's often the case that you want to add metadata after the
FROM oci-archive:....Assisted-by: Claude Opus 4.6
/kind bug