-
Notifications
You must be signed in to change notification settings - Fork 119
ostree-ext/filter_tar_async: flush decompressor stream #1228
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
Hm should have probably run tests locally first 😆 |
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.
Ahh, that definitely explains why it happens reliably with zstd:chunked.
But...hmmm...we have still seen it occasionally for non zstd:chunked layers though too, could it be that even gzip has a similar thing, just less likely?
Yeah I'm not familiar with the specifics on gzip but that could be the case. Looking at the failing tests though, it looks like maybe when we do the filtering that causes us to not always read to the end of even the basic tar stream? I guess that could also cause the same behavior. Should be easy enough to test by writing a large enough file at the end of the stream that ends up getting filtered out. |
If the last item is filtered out, then that will definitely happen. But even there, in the tar format there's trailing zeros to indicate end-of-archive, and I wonder if tar-rs is always consuming those bytes? It probably should be, but not 100% sure. |
Well I suppose the "cheater" fix here is to just |
We need to read anything past the tar stream, otherwise we'll deadlock via skopeo in FinishPipe. Also remove the bit where we hold the pipe open longer, we shouldn't need to do that anymore because we've ensured we've read everything out of it by this point. Resolves: bootc-dev#1204 Signed-off-by: John Eckersberg <jeckersb@redhat.com>
Another thing re: "why does gzip work better", note that for the gzip case we explicitly create a BufReader since it's required by |
if n != 0 { | ||
tracing::debug!("Read extra {n} bytes at end of decompressor stream"); | ||
} | ||
|
||
// Pass ownership of the input stream back to the caller - see below. |
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.
This comment needs removed (If we actually remove this logic)
This merged before I pushed an updated version, so follow up: - Be explicit about also flushing the tar stream, since that can also have trailing data. - Remove unneeded comment about passing the input stream Signed-off-by: John Eckersberg <jeckersb@redhat.com>
We do already have tests in ostree-ext for zstd and zstd:chunked: bootc/ostree-ext/tests/it/main.rs Lines 1674 to 1684 in c94cfdf
but obviously those were passing before this change. I was only able to get it to break with a sufficiently large container image (empty worked, 50MB worked, 100MB intermittently failed, 200MB always failed). So I'll add a test to generate a large (1GB?) zstd/zstd:chunked image and import that. |
I am able to reproduce this as well with |
Your image also fails using the same command I was using before (just
|
Followup to bootc-dev#1228 We use the decompressor a couple of times in unencapsulate_base in addition to the previous fix in filter_tar_async. Instead of duplicating the decompressor flush logic in each place, wrap the decompressor in a struct and implement Drop for it so we always automatically flush the input stream when we're finished with it. Signed-off-by: John Eckersberg <jeckersb@redhat.com>
Followup PR should fix this |
We need to read anything past the tar stream, otherwise we'll deadlock
via skopeo in FinishPipe.
Also remove the bit where we hold the pipe open longer, we shouldn't
need to do that anymore because we've ensured we've read everything
out of it by this point.
Resolves: #1204
Signed-off-by: John Eckersberg jeckersb@redhat.com