mirror of
https://github.com/k3s-io/kubernetes.git
synced 2026-01-16 14:57:35 +00:00
Automatic merge from submit-queue etcd3/watcher: fix goroutine leak if ctx is canceled ### Problem In reflector.go, it could probably call Stop() without retrieving all results from ResultChan(). See [here](https://github.com/kubernetes/kubernetes/blob/master/pkg/client/cache/reflector.go#L369). A potential leak is that when an error has happened, it could block on resultChan, and then cancelling context in Stop() wouldn't unblock it. ### What's this PR? This fixes the problem by making it also select ctx.Done and cancel context afterwards if error happened.