build: commit an empty layer instead of a layer with nothing in it#6873
build: commit an empty layer instead of a layer with nothing in it#6873nalind wants to merge 2 commits into
Conversation
|
Ephemeral COPR build failed. @containers/packit-build please check. |
1 similar comment
|
Ephemeral COPR build failed. @containers/packit-build please check. |
Add a flag to CommitOptions which will drop the layer blob for the working container's layer, and mark it as an empty layer in the history, if the generated diff is just a block of zero bytes. Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
When `buildah build`ing an image in single-layer mode, if the generated diff has nothing in it, omit the blob and set the EmptyLayer field in the final history entry, which would otherwise correspond to it. Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2cd9c85 to
a23b7ba
Compare
|
LGTM |
| // don't bother, because it's highly unlikely), suppress it. | ||
| if i.emptyLayerIfEmptyDiff && layerID == i.layerID { | ||
| switch size { | ||
| case 0, 512, 1024, 2048: |
There was a problem hiding this comment.
Those are multiples of the record size used by tar(5) - an archive with no entries in it still includes the end-of-archive marker, which is usually 1024 bytes, i.e., two records full of zero bytes. The rest of the possible lengths are just guesses, which should be harmless since still we only discard layers of that length if the diff is all zero bytes.
| # sha512sum([0]{}) | ||
| assert lastdiffid != sha512:cf83e1357eefb8bdf1542850d66d8007d620e4050b5715dc83f4a921d36ce9ce47d0d13c5d85f2b0ff8318d2877eec2f63b931bd47417a81a538327af927da3e | ||
| # sha512sum([1024]{}) | ||
| assert lastdiffid != sha512:8efb4f73c5655351c444eb109230c556d39e2c7624e9c11abc9e3fb4b9b9254218cc5085b454a9698d085cfa92198491f07a723be4574adc70617b73eb0b6461 |
There was a problem hiding this comment.
Is this correct? Should we use some flag or config to force buildah to use sha512?
There was a problem hiding this comment.
We currently don't have a flag to do that. This is an attempt at predicting the future.
What type of PR is this?
/kind feature
What this PR does / why we need it:
When
buildah building an image in single-layer mode, if the generated diff has nothing in it, omit the blob and set the EmptyLayer field in the final history entry, which would otherwise correspond to it.How to verify it
New integration test!
Which issue(s) this PR fixes:
Fixes #6860
Special notes for your reviewer:
Does this PR introduce a user-facing change?