GoogleContainerTools / GoogleContainerTools/skaffold
Flaky test `writeFilesToTar`
- Dominant language
- Go
- Stars
- 15.9k
- Forks
- 1.7k
- Avg merge
- 3d 9h
- Merged PRs (30d)
- 10
Description
The `writeFilesToTar` is flaky, showing this error when it fails:
```
=== Failed Tests ===
/v2/pkg/skaffold/util/TestAddFileToTarTimeout
=== CONT TestAddFileToTarTimeout
testing.go:1319: race detected during execution of test
--- FAIL: TestAddFileToTarTimeout (1.00s)
/v2/pkg/skaffold/util/TestAddFileToTarTimeout/TestAddFileToTarTimeout
==================
WARNING: DATA RACE
Read at 0x00c00086ad80 by goroutine 253:
archive/tar.(*Writer).Write()
/opt/hostedtoolcache/go/1.19.10/x64/src/archive/tar/writer.go:435 +0x50
io.copyBuffer()
/opt/hostedtoolcache/go/1.19.10/x64/src/io/io.go:429 +0x2de
io.Copy()
/opt/hostedtoolcache/go/1.19.10/x64/src/io/io.go:386 +0x9b
github.com/GoogleContainerTools/skaffold/v2/pkg/skaffold/util.addFileToTar.func1()
/home/runner/work/skaffold/skaffold/pkg/skaffold/util/tar.go:168 +0x76
Previous write at 0x00c00086ad80 by goroutine 251:
archive/tar.(*Writer).Close()
/opt/hostedtoolcache/go/1.19.10/x64/src/archive/tar/writer.go:484 +0x1ac
github.com/GoogleContainerTools/skaffold/v2/pkg/skaffold/util.CreateTar.func1()
/home/runner/work/skaffold/skaffold/pkg/skaffold/util/tar.go:53 +0x39
runtime.deferreturn()
/opt/hostedtoolcache/go/1.19.10/x64/src/runtime/panic.go:[476](https://github.com/GoogleContainerTools/skaffold/actions/runs/5380228908/jobs/9762625489#step:5:477) +0x32
github.com/GoogleContainerTools/skaffold/v2/pkg/skaffold/util.TestAddFileToTarTimeout.func1()
/home/runner/work/skaffold/skaffold/pkg/skaffold/util/tar_test.go:301 +0x344
github.com/GoogleContainerTools/skaffold/v2/testutil.Run.func1()
/home/runner/work/skaffold/skaffold/testutil/util.go:262 +0x79
testing.tRunner()
/opt/hostedtoolcache/go/1.19.10/x64/src/testing/testing.go:1446 +0x216
testing.(*T).Run.func1()
/opt/hostedtoolcache/go/1.19.10/x64/src/testing/testing.go:1[493](https://github.com/GoogleContainerTools/skaffold/actions/runs/5380228908/jobs/9762625489#step:5:494) +0x47
Goroutine 253 (running) created at:
github.com/GoogleContainerTools/skaffold/v2/pkg/skaffold/util.addFileToTar()
/home/runner/work/skaffold/skaffold/pkg/skaffold/util/tar.go:167 +0x8e9
github.com/GoogleContainerTools/skaffold/v2/pkg/skaffold/util.CreateTar()
/home/runner/work/skaffold/skaffold/pkg/skaffold/util/tar.go:56 +0x365
github.com/GoogleContainerTools/skaffold/v2/pkg/skaffold/util.TestAddFileToTarTimeout.func1()
/home/runner/work/skaffold/skaffold/pkg/skaffold/util/tar_test.go:301 +0x344
github.com/GoogleContainerTools/skaffold/v2/testutil.Run.func1()
/home/runner/work/skaffold/skaffold/testutil/util.go:262 +0x79
testing.tRunner()
/opt/hostedtoolcache/go/1.19.10/x64/src/testing/testing.go:1446 +0x216
testing.(*T).Run.func1()
/opt/hostedtoolcache/go/1.19.10/x64/src/testing/testing.go:1493 +0x47
Goroutine 251 (running) created at:
testing.(*T).Run()
/opt/hostedtoolcache/go/1.19.10/x64/src/testing/testing.go:1493 +0x75d
github.com/GoogleContainerTools/skaffold/v2/testutil.Run()
/home/runner/work/skaffold/skaffold/testutil/util.go:261 +0xfd
github.com/GoogleContainerTools/skaffold/v2/pkg/skaffold/util.TestAddFileToTarTimeout()
/home/runner/work/skaffold/skaffold/pkg/skaffold/util/tar_test.go:289 +0x39
testing.tRunner()
/opt/hostedtoolcache/go/1.19.10/x64/src/testing/testing.go:1446 +0x216
testing.(*T).Run.func1()
/opt/hostedtoolcache/go/1.19.10/x64/src/testing/testing.go:1493 +0x47
==================
testing.go:1319: race detected during execution of test
--- FAIL: TestAddFileToTarTimeout/TestAddFileToTarTimeout (1.00s)
```
An explanation of what's hapening:
https://github.com/GoogleContainerTools/skaffold/pull/8917#issuecomment-1607805731
Contributor guide
Research direction
The failure points to pkg/skaffold/util/tar.go, especially addFileToTar and CreateTar, and pkg/skaffold/util/tar_test.go at TestAddFileToTarTimeout. Run that test with Go's race detector and inspect the referenced pull request discussion; done means the test no longer reports a race while preserving the tar timeout behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go
- Domain
- testing, tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100