Skip to content

Conversation

@ktock
Copy link
Member

@ktock ktock commented Sep 9, 2021

moby/buildkit#2352

Currently, eStargz writer (estargz.Writer) rewrites tar headers of the original tar so it's not possible to recover the original tar blob from the result eStargz. This lossy behaviour can be problematic when the client needs to convert tar to eStargz and then recover the original tar from the result eStargz.

For solving this issue, this commit adds AppendTarLossLess API to estargz.Writer. This allows creating eStargz without changing the original tar blob. estargz.Unpack API enables to decompress the eStargz and get the original tar blob.

Note that this losslessness implies a limitation that the writer cannot support compressing a tar that contains a file named stargz.index.json because estargz cannot be created without overwriting that file. When the caller appends an eStargz blob to the writer, it should be decompressed to a tar using estargz.Unpack API.

cc @tonistiigi
Thank you for the discussion.

sw := NewWriterWithCompressor(wantBuf, cl)
sw.ChunkSize = tt.chunkSize
if err := sw.AppendTar(tarBlob); err != nil {
t.Fatalf("faield to append tar to want stargz: %v", err)
Copy link
Member

Choose a reason for hiding this comment

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

nit: typo

@AkihiroSuda AkihiroSuda merged commit a3ecdc9 into containerd:main Sep 10, 2021
@ktock ktock deleted the lossless branch October 7, 2022 13:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants