reflector: close an established watcher when the StopCh was closed

Kubernetes-commit: 26f113be2fc71c7a41a59145eee5d4da9d062b9e
This commit is contained in:
Lukasz Szaszkiewicz
2023-10-03 13:49:21 +02:00
committed by Kubernetes Publisher
parent d6dc079df2
commit 2c9d749027
2 changed files with 27 additions and 0 deletions

View File

@@ -397,6 +397,11 @@ func (r *Reflector) watch(w watch.Interface, stopCh <-chan struct{}, resyncerrc
// give the stopCh a chance to stop the loop, even in case of continue statements further down on errors
select {
case <-stopCh:
// we can only end up here when the stopCh
// was closed after a successful watchlist or list request
if w != nil {
w.Stop()
}
return nil
default:
}