Skip to content

Commit adc7380

Browse files
authored
Merge pull request #3650 from ntnn/goleak-workaround
Use a fork of goleak with IgnoreCreatedBy
2 parents 9ba71d6 + c8fd0bd commit adc7380

File tree

3 files changed

+18
-3
lines changed

3 files changed

+18
-3
lines changed

go.mod

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,3 +220,7 @@ replace (
220220
github.com/kcp-dev/client-go => ./staging/src/github.com/kcp-dev/client-go
221221
github.com/kcp-dev/code-generator/v3 => ./staging/src/github.com/kcp-dev/code-generator
222222
)
223+
224+
// This fork is required to use IgnoreCreatedBy. The PR to add this
225+
// feature is here: https://github.com/uber-go/goleak/pull/136
226+
replace go.uber.org/goleak => github.com/ntnn/goleak v1.2.2-0.20251003233619-cbb740da4265

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,8 @@ github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 h1:C3w9PqII01/Oq
232232
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ=
233233
github.com/mxk/go-flowrate v0.0.0-20140419014527-cca7078d478f h1:y5//uYreIhSUg3J1GEMiLbxo1LJaP8RfCpH6pymGZus=
234234
github.com/mxk/go-flowrate v0.0.0-20140419014527-cca7078d478f/go.mod h1:ZdcZmHo+o7JKHSa8/e818NopupXU1YMK5fe1lsApnBw=
235+
github.com/ntnn/goleak v1.2.2-0.20251003233619-cbb740da4265 h1:QNwRvEYOwSkKQzx87unvskM6+QzA+cIE7gUvZJvmI6c=
236+
github.com/ntnn/goleak v1.2.2-0.20251003233619-cbb740da4265/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE=
235237
github.com/onsi/ginkgo/v2 v2.21.0 h1:7rg/4f3rB88pb5obDgNZrNHrQ4e6WpjonchcpuBRnZM=
236238
github.com/onsi/ginkgo/v2 v2.21.0/go.mod h1:7Du3c42kxCUegi0IImZ1wUQzMBVecgIHjR1C+NkhLQo=
237239
github.com/onsi/gomega v1.35.1 h1:Cwbd75ZBPxFSuZ6T+rN/WCb/gOc6YgFBXLlZLhC7Ds4=
@@ -345,8 +347,6 @@ go.opentelemetry.io/otel/trace v1.33.0/go.mod h1:uIcdVUZMpTAmz0tI1z04GoVSezK37Cb
345347
go.opentelemetry.io/proto/otlp v1.4.0 h1:TA9WRvW6zMwP+Ssb6fLoUIuirti1gGbP28GcKG1jgeg=
346348
go.opentelemetry.io/proto/otlp v1.4.0/go.mod h1:PPBWZIP98o2ElSqI35IHfu7hIhSwvc5N38Jw8pXuGFY=
347349
go.uber.org/atomic v1.4.0/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE=
348-
go.uber.org/goleak v1.3.1-0.20241121203838-4ff5fa6529ee h1:uOMbcH1Dmxv45VkkpZQYoerZFeDncWpjbN7ATiQOO7c=
349-
go.uber.org/goleak v1.3.1-0.20241121203838-4ff5fa6529ee/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE=
350350
go.uber.org/multierr v1.1.0/go.mod h1:wR5kodmAFQ0UK8QlbwjlSNy0Z68gJhDJUG5sjR94q/0=
351351
go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0=
352352
go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y=

test/integration/workspace/leak_test.go

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,17 @@ func createAndDeleteWs(ctx context.Context, t *testing.T, kcpClient kcpclientset
8888
time.Sleep(2 * time.Second)
8989
}
9090

91+
var (
92+
// These are goroutines that can pop up randomly during KCP
93+
// operations and aren't indicative of a leak when deleting
94+
// a workspace.
95+
randomGoroutineSources = []goleak.Option{
96+
goleak.IgnoreCreatedBy("net/http.(*Server).Serve"),
97+
goleak.IgnoreCreatedBy("golang.org/x/net/http2.(*Transport).newClientConn"),
98+
goleak.IgnoreCreatedBy("golang.org/x/net/http2.(*serverConn).serve"),
99+
}
100+
)
101+
91102
func TestWorkspaceDeletionLeak(t *testing.T) {
92103
ctx, cancel := context.WithCancel(context.Background())
93104
t.Cleanup(cancel) // TODO update in go1.24
@@ -105,7 +116,7 @@ func TestWorkspaceDeletionLeak(t *testing.T) {
105116

106117
t.Logf("Check for leftover goroutines")
107118
kcptestinghelpers.Eventually(t, func() (bool, string) {
108-
if err := goleak.Find(curGoroutines); err != nil {
119+
if err := goleak.Find(append(randomGoroutineSources, curGoroutines)...); err != nil {
109120
return false, err.Error()
110121
}
111122
return true, ""

0 commit comments

Comments
 (0)