Skip to content

Commit

Permalink
Merge pull request kubernetes#105605 from sttts/sttts-watch-cache-mul…
Browse files Browse the repository at this point in the history
…tiple-blockers

apiserver/watchcache: doc watch event fan-out to blocked watchers better
  • Loading branch information
k8s-ci-robot authored Oct 11, 2021
2 parents dc9c571 + 94b2bb1 commit 194a3de
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions staging/src/k8s.io/apiserver/pkg/storage/cacher/cacher.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 194a3de

Please sign in to comment.