diff --git a/test/e2e/node/pods.go b/test/e2e/node/pods.go index 8f926d1d2057f..f2714beb6bf51 100644 --- a/test/e2e/node/pods.go +++ b/test/e2e/node/pods.go @@ -273,6 +273,7 @@ var _ = SIGDescribe("Pods Extended", func() { start := time.Now() created := podClient.Create(pod) ch := make(chan []watch.Event) + numEvents := 0 go func() { defer close(ch) w, err := podClient.Watch(context.TODO(), metav1.ListOptions{ @@ -298,6 +299,7 @@ var _ = SIGDescribe("Pods Extended", func() { } } ch <- events + numEvents = len(events) }() t := time.Duration(rand.Intn(delay)) * time.Millisecond @@ -319,6 +321,11 @@ var _ = SIGDescribe("Pods Extended", func() { } case <-time.After(5 * time.Minute): framework.Failf("timed out waiting for watch events for %s", pod.Name) + // Iterate over the events and stop them to avoid leak + for i := 0; i < numEvents; i++ { + w := <-ch + w.Stop() + } } end := time.Now()