Merge pull request #105605 from sttts/sttts-watch-cache-multiple-blockers

apiserver/watchcache: doc watch event fan-out to blocked watchers better
This commit is contained in:
Kubernetes Prow Robot 2021-10-11 09:32:40 -07:00 committed by GitHub
commit 194a3dea5d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

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) {