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
Fix tar PAX format handling #1414
Conversation
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
pkg/v1/mutate/mutate.go
Outdated
// tar.Next() sometimes mistakenly guesses format as USTAR, which creates a problem: | ||
// if the header.Name is > 100 characters long, WriteHeader() returns an error like | ||
// "archive/tar: cannot encode header: Format specifies USTAR; and USTAR cannot encode Name=...". | ||
// To fix, change format from USTAR to PAX on Windows | ||
if isWin && header.Format == tar.FormatUSTAR { | ||
header.Format = tar.FormatPAX | ||
} |
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.
Ugh. This seems like the kind of thing I'd expect archive/tar to handle for us... :-/
Can you add a link to the issue in the comment, and maybe any other helpful issues you've found while debugging this? That will help remind me better why this is here when I rediscover it in six months, or if I have the same Windows-specific issue elsewhere and come back here to try to remember what the deal was.
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.
There is also viable path that linuxkit chose - to force PAX on output linuxkit/linuxkit#3141
Maybe force PAX and document it using reasoning in pull request above?
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.
something like here (with linked pull request)(https://github.com/linuxkit/linuxkit/blob/master/src/cmd/linuxkit/moby/image.go#L216)
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.
I'd be okay with just always setting this.
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.
SGTM 👍
pkg/v1/mutate/mutate.go
Outdated
// tar.Next() sometimes mistakenly guesses format as USTAR, which creates a problem: | ||
// if the header.Name is > 100 characters long, WriteHeader() returns an error like | ||
// "archive/tar: cannot encode header: Format specifies USTAR; and USTAR cannot encode Name=...". | ||
// To fix, change format from USTAR to PAX on Windows | ||
if isWin && header.Format == tar.FormatUSTAR { | ||
header.Format = tar.FormatPAX | ||
} |
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.
I'd be okay with just always setting this.
@@ -297,7 +308,9 @@ func extract(img v1.Image, w io.Writer) error { | |||
// any entries with a matching (or child) name | |||
fileMap[name] = tombstone || !(header.Typeflag == tar.TypeDir) | |||
if !tombstone { | |||
tarWriter.WriteHeader(header) | |||
if err := tarWriter.WriteHeader(header); err != nil { |
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.
Thank you!
Codecov Report
@@ Coverage Diff @@
## main #1414 +/- ##
==========================================
- Coverage 73.38% 73.36% -0.02%
==========================================
Files 115 115
Lines 8750 8756 +6
==========================================
+ Hits 6421 6424 +3
- Misses 1688 1690 +2
- Partials 641 642 +1
Help us with your feedback. Take ten seconds to tell us how you rate us. |
Fixes #1412