Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -220,3 +220,7 @@ replace (
github.com/kcp-dev/client-go => ./staging/src/github.com/kcp-dev/client-go
github.com/kcp-dev/code-generator/v3 => ./staging/src/github.com/kcp-dev/code-generator
)

// This fork is required to use IgnoreCreatedBy. The PR to add this
// feature is here: https://github.com/uber-go/goleak/pull/136
replace go.uber.org/goleak => github.com/ntnn/goleak v1.2.2-0.20251003233619-cbb740da4265
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,8 @@ github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 h1:C3w9PqII01/Oq
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ=
github.com/mxk/go-flowrate v0.0.0-20140419014527-cca7078d478f h1:y5//uYreIhSUg3J1GEMiLbxo1LJaP8RfCpH6pymGZus=
github.com/mxk/go-flowrate v0.0.0-20140419014527-cca7078d478f/go.mod h1:ZdcZmHo+o7JKHSa8/e818NopupXU1YMK5fe1lsApnBw=
github.com/ntnn/goleak v1.2.2-0.20251003233619-cbb740da4265 h1:QNwRvEYOwSkKQzx87unvskM6+QzA+cIE7gUvZJvmI6c=
github.com/ntnn/goleak v1.2.2-0.20251003233619-cbb740da4265/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE=
github.com/onsi/ginkgo/v2 v2.21.0 h1:7rg/4f3rB88pb5obDgNZrNHrQ4e6WpjonchcpuBRnZM=
github.com/onsi/ginkgo/v2 v2.21.0/go.mod h1:7Du3c42kxCUegi0IImZ1wUQzMBVecgIHjR1C+NkhLQo=
github.com/onsi/gomega v1.35.1 h1:Cwbd75ZBPxFSuZ6T+rN/WCb/gOc6YgFBXLlZLhC7Ds4=
Expand Down Expand Up @@ -345,8 +347,6 @@ go.opentelemetry.io/otel/trace v1.33.0/go.mod h1:uIcdVUZMpTAmz0tI1z04GoVSezK37Cb
go.opentelemetry.io/proto/otlp v1.4.0 h1:TA9WRvW6zMwP+Ssb6fLoUIuirti1gGbP28GcKG1jgeg=
go.opentelemetry.io/proto/otlp v1.4.0/go.mod h1:PPBWZIP98o2ElSqI35IHfu7hIhSwvc5N38Jw8pXuGFY=
go.uber.org/atomic v1.4.0/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE=
go.uber.org/goleak v1.3.1-0.20241121203838-4ff5fa6529ee h1:uOMbcH1Dmxv45VkkpZQYoerZFeDncWpjbN7ATiQOO7c=
go.uber.org/goleak v1.3.1-0.20241121203838-4ff5fa6529ee/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE=
go.uber.org/multierr v1.1.0/go.mod h1:wR5kodmAFQ0UK8QlbwjlSNy0Z68gJhDJUG5sjR94q/0=
go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0=
go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y=
Expand Down
13 changes: 12 additions & 1 deletion test/integration/workspace/leak_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,17 @@ func createAndDeleteWs(ctx context.Context, t *testing.T, kcpClient kcpclientset
time.Sleep(2 * time.Second)
}

var (
// These are goroutines that can pop up randomly during KCP
// operations and aren't indicative of a leak when deleting
// a workspace.
randomGoroutineSources = []goleak.Option{
goleak.IgnoreCreatedBy("net/http.(*Server).Serve"),
goleak.IgnoreCreatedBy("golang.org/x/net/http2.(*Transport).newClientConn"),
goleak.IgnoreCreatedBy("golang.org/x/net/http2.(*serverConn).serve"),
}
)

func TestWorkspaceDeletionLeak(t *testing.T) {
ctx, cancel := context.WithCancel(context.Background())
t.Cleanup(cancel) // TODO update in go1.24
Expand All @@ -105,7 +116,7 @@ func TestWorkspaceDeletionLeak(t *testing.T) {

t.Logf("Check for leftover goroutines")
kcptestinghelpers.Eventually(t, func() (bool, string) {
if err := goleak.Find(curGoroutines); err != nil {
if err := goleak.Find(append(randomGoroutineSources, curGoroutines)...); err != nil {
return false, err.Error()
}
return true, ""
Expand Down