From 3c777cb09fe8cdd3b240b277db817d9d1a97c165 Mon Sep 17 00:00:00 2001 From: Tiger Kaovilai Date: Tue, 10 Sep 2024 19:25:17 -0400 Subject: [PATCH] pkg/podvolume/backupper_test.go:597:14: the cancel function returned by context.WithTimeout should be called, not discarded, to avoid a context leak Signed-off-by: Tiger Kaovilai --- pkg/podvolume/backupper_test.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/pkg/podvolume/backupper_test.go b/pkg/podvolume/backupper_test.go index 16d4ce286..fe50f9e30 100644 --- a/pkg/podvolume/backupper_test.go +++ b/pkg/podvolume/backupper_test.go @@ -594,7 +594,10 @@ func (l *logHook) Fire(entry *logrus.Entry) error { } func TestWaitAllPodVolumesProcessed(t *testing.T) { - timeoutCtx, _ := context.WithTimeout(context.Background(), 1*time.Second) + timeoutCtx, cancelFunc := context.WithTimeout(context.Background(), 1*time.Second) + defer func() { + cancelFunc() + }() cases := []struct { name string ctx context.Context