Skip to content
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

chunked: flush the input tarball to the output #1772

Merged
merged 2 commits into from
Dec 13, 2023

Conversation

giuseppe
Copy link
Member

Flush the entire input tarball to the output in the zstd:chunked stream writer. This is needed to include any trailing zeros that affect the uncompressed digest.

Closes: #1771

Signed-off-by: Giuseppe Scrivano [email protected]

Copy link
Contributor

openshift-ci bot commented Dec 12, 2023

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: giuseppe

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@rhatdan
Copy link
Member

rhatdan commented Dec 12, 2023

LGTM
But linter is not happy.

@giuseppe
Copy link
Member Author

the lint failure is unrelated, I've a patch in https://github.com/containers/storage/pull/1769/commits to fix it

Copy link
Collaborator

@mtrmac mtrmac left a comment

Choose a reason for hiding this comment

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

LGTM, modulo the tests.


// make sure the entire tarball is flushed to the output as it might contain
// some trailing zeros that affect the checksum.
if _, err := io.Copy(zstdWriter, its); err != nil {
Copy link
Collaborator

Choose a reason for hiding this comment

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

For the record: This looked very surprising to me (if notthing else, I doubted that after passing its to tar.NewReader there are any promises at all about the position of its)…

But tar-split internally does the same thing in https://github.com/vbatts/tar-split/blob/9a95e026024d3929928021244d72e59f758616b3/tar/asm/disassemble.go#L121-L151 .

(And for the purposes of this PR, we don’t care whether the unexpected trailing padding is recorded into tar-split metadata (that is important, but hopefully ensured by existing code), but whether we write it into the zstdWriter unmodified; so we must do that separately.)

@rhatdan
Copy link
Member

rhatdan commented Dec 13, 2023

I merged the other PR which I believe fixes the lint, could you rebase to make sure tests pass.

close the pipe immediately when the file is closed to avoid a possible
deadlock if the other end is waiting for EOF on the writer side.

Signed-off-by: Giuseppe Scrivano <[email protected]>
Flush the entire input tarball to the output in the zstd:chunked
stream writer.  This is needed to include any trailing zeros that
affect the uncompressed digest.

Closes: containers#1771

Signed-off-by: Giuseppe Scrivano <[email protected]>
@rhatdan
Copy link
Member

rhatdan commented Dec 13, 2023

/lgtm

@openshift-ci openshift-ci bot added the lgtm label Dec 13, 2023
@openshift-merge-bot openshift-merge-bot bot merged commit 1a86024 into containers:main Dec 13, 2023
18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

podman push --compression-format=zstd:chunked generates invalid OCI images
3 participants