Skip to content

Commit 34f3d9d

Browse files
cvvzk8s-infra-cherrypick-robot
authored andcommitted
fix: goroutine leak
1 parent a51b2f0 commit 34f3d9d

File tree

18 files changed

+1059
-1
lines changed

18 files changed

+1059
-1
lines changed

go.mod

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ require (
2626
github.com/onsi/gomega v1.37.0
2727
github.com/rubiojr/go-vhd v0.0.0-20200706105327-02e210299021
2828
github.com/stretchr/testify v1.10.0
29+
go.uber.org/goleak v1.3.0
2930
go.uber.org/mock v0.5.1
3031
golang.org/x/net v0.38.0
3132
golang.org/x/sys v0.32.0

pkg/util/util.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ type TimeoutFunc func() (err error)
202202
// WaitUntilTimeout waits for the exec function to complete or return timeout error
203203
func WaitUntilTimeout(timeout time.Duration, execFunc ExecFunc, timeoutFunc TimeoutFunc) error {
204204
// Create a channel to receive the result of the azcopy exec function
205-
done := make(chan bool)
205+
done := make(chan bool, 1)
206206
var err error
207207

208208
// Start exec function in a goroutine

pkg/util/util_test.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import (
2323
"testing"
2424
"time"
2525

26+
"go.uber.org/goleak"
2627
gomock "go.uber.org/mock/gomock"
2728
)
2829

@@ -352,6 +353,7 @@ func TestParseAzcopyJobShow(t *testing.T) {
352353
}
353354

354355
func TestWaitUntilTimeout(t *testing.T) {
356+
defer goleak.VerifyNone(t)
355357
tests := []struct {
356358
desc string
357359
timeout time.Duration
@@ -378,6 +380,7 @@ func TestWaitUntilTimeout(t *testing.T) {
378380
return nil
379381
},
380382
timeoutFunc: func() error {
383+
time.Sleep(2 * time.Second)
381384
return fmt.Errorf("timeout error")
382385
},
383386
expectedErr: fmt.Errorf("timeout error"),

vendor/go.uber.org/goleak/.gitignore

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/go.uber.org/goleak/.golangci.yml

Lines changed: 28 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/go.uber.org/goleak/CHANGELOG.md

Lines changed: 74 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/go.uber.org/goleak/LICENSE

Lines changed: 21 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/go.uber.org/goleak/Makefile

Lines changed: 45 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/go.uber.org/goleak/README.md

Lines changed: 74 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/go.uber.org/goleak/doc.go

Lines changed: 22 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)