apiserver/watchcache: doc watch event fan-out to blocked watchers better

Kubernetes-commit: 94b2bb1d3dcfe7973329cc56024f449adde4086c
This commit is contained in:
Dr. Stefan Schimanski 2021-10-08 17:05:27 +02:00 committed by Kubernetes Publisher
parent 09b2241faf
commit c0ff3feb85
1 changed files with 5 additions and 2 deletions

View File

@ -934,8 +934,11 @@ func (c *Cacher) dispatchEvent(event *watchCacheEvent) {
timeout := c.dispatchTimeoutBudget.takeAvailable()
c.timer.Reset(timeout)
// Make sure every watcher will try to send event without blocking first,
// even if the timer has already expired.
// Send event to all blocked watchers. As long as timer is running,
// `add` will wait for the watcher to unblock. After timeout,
// `add` will not wait, but immediately close a still blocked watcher.
// Hence, every watcher gets the chance to unblock itself while timer
// is running, not only the first ones in the list.
timer := c.timer
for _, watcher := range c.blockedWatchers {
if !watcher.add(event, timer) {