-
Notifications
You must be signed in to change notification settings - Fork 18.6k
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
pkg/tarsum: fix unit test for Go 1.11+ #37498
Conversation
Since go-1.11beta1 archive/tar, tar headers with Typeflag == TypeRegA (numeric 0) (which is the default unless explicitly initialized) are modified to have Typeflag set to either tar.TypeReg (character value '0', not numeric 0) or tar.TypeDir (character value '5') [1]. This results in different Typeflag value in the resulting header, leading to a different Checksum, and causing the following test case errors: > 12:09:14 --- FAIL: TestTarSums (0.05s) > 12:09:14 tarsum_test.go:393: expecting > [tarsum+sha256:8bf12d7e67c51ee2e8306cba569398b1b9f419969521a12ffb9d8875e8836738], > but got > [tarsum+sha256:75258b2c5dcd9adfe24ce71eeca5fc5019c7e669912f15703ede92b1a60cb11f] > ... (etc.) All the other code explicitly sets the Typeflag field, but this test case is not, causing the incompatibility with Go 1.11. Therefore, the fix is to set TypeReg explicitly, and change the expected checksums in test cases). Alternatively, we can vendor archive/tar again (for the 100th time), but given that the issue is limited to the particular test case it does not make sense. This fixes the test for all Go versions. [1] https://go-review.googlesource.com/c/go/+/85656 Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
This one was part of #37358 |
ppc CI failure is #37408 |
Related discussion: #37358 (review) |
Uid: 0, | ||
Gid: 0, | ||
Size: opts.size, | ||
Typeflag: tar.TypeReg, |
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 is the change that makes Go 1.10 switch to the same behavior as Go 1.11? With this change, do we still need the vendored archive
package (on Go 1.10)?
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 is the change that makes Go 1.10 switch to the same behavior as Go 1.11?
Yes. It just fixes the test case by explicitly specifying the file type (rather than using an obsolete default value).
With this change, do we still need the vendored archive package (on Go 1.10)?
Yes we do (it is there to fix a different problem about static build).
Moving this back to "design review", so that we can complete the discussion on this change from a behavioural perspective 😅 |
Let me reiterate it here. All the tarballs generated by docker have |
I should learn how to read 😅 I see you referred to that in the linked issue, but we were also discussing the "cache breaking" |
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
ping @tonistiigi @dmcgowan
I have briefly checked it, and it looks like
so there should be no cache breakage. |
Was this changed in 1.10? As in, did we already have a cache breakage
This is not related to build cache breakage I don't think build cache breaking should be a blocker, I was just bringing it up so we are aware if there is breakage. After such a breakage we get users coming back complaining about a performance regression in build time and resource usage, when in reality it is just their builds being run without the cache hit they had with the previous version. Regardless, this change LGTM |
The change I'm talking about (essentially
I stand corrected. Could you explain what kind of changes in |
If all tars created by CLI for LGTM |
Codecov Report
@@ Coverage Diff @@
## master #37498 +/- ##
=========================================
Coverage ? 34.95%
=========================================
Files ? 610
Lines ? 44886
Branches ? 0
=========================================
Hits ? 15690
Misses ? 27076
Partials ? 2120 |
Since go-1.11beta1
archive/tar
, tar headers withTypeflag == TypeRegA
(numeric value 0, which is the default unless explicitly initialized) are modified to have Typeflag set to eithertar.TypeReg
(character value '0', not numeric 0) ortar.TypeDir
(character value '5') [1]. This results in differentTypeflag
value in the resulting header, leading to a differentChecksum
, and causing the following test case errors:All the other code explicitly sets the
Typeflag
field, but this test case does not, causing the incompatibility with Go 1.11. Therefore the fix is to setTypeReg
value explicitly, and change the expected checksumsin test cases.
Alternatively, we can vendor archive/tar again (for the 100th time), but given that the issue is limited to the particular test case it does not make sense.
This fixes the test for all Go versions.
[1] https://go-review.googlesource.com/c/go/+/85656