mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-24 04:06:03 +00:00
Merge pull request #90524 from kubernetes/revert-90249-bookmark_every_minute
Revert "Send watch bookmarks every minute"
This commit is contained in:
commit
6abb8ebd19
@ -171,7 +171,10 @@ func newTimeBucketWatchers(clock clock.Clock) *watcherBookmarkTimeBuckets {
|
|||||||
// adds a watcher to the bucket, if the deadline is before the start, it will be
|
// adds a watcher to the bucket, if the deadline is before the start, it will be
|
||||||
// added to the first one.
|
// added to the first one.
|
||||||
func (t *watcherBookmarkTimeBuckets) addWatcher(w *cacheWatcher) bool {
|
func (t *watcherBookmarkTimeBuckets) addWatcher(w *cacheWatcher) bool {
|
||||||
nextTime := w.nextBookmarkTime(t.clock.Now())
|
nextTime, ok := w.nextBookmarkTime(t.clock.Now())
|
||||||
|
if !ok {
|
||||||
|
return false
|
||||||
|
}
|
||||||
bucketID := nextTime.Unix()
|
bucketID := nextTime.Unix()
|
||||||
t.lock.Lock()
|
t.lock.Lock()
|
||||||
defer t.lock.Unlock()
|
defer t.lock.Unlock()
|
||||||
@ -1216,26 +1219,13 @@ func (c *cacheWatcher) add(event *watchCacheEvent, timer *time.Timer) bool {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// bookmarkHeartbeatFrequency defines how frequently bookmarks should be
|
func (c *cacheWatcher) nextBookmarkTime(now time.Time) (time.Time, bool) {
|
||||||
// under regular conditions.
|
// For now we return 2s before deadline (and maybe +infinity is now already passed this time)
|
||||||
const bookmarkHeartbeatFrequency = time.Minute
|
// but it gives us extensibility for the future(false when deadline is not set).
|
||||||
|
|
||||||
func (c *cacheWatcher) nextBookmarkTime(now time.Time) time.Time {
|
|
||||||
// We try to send bookmarks:
|
|
||||||
// (a) roughly every minute
|
|
||||||
// (b) right before the watcher timeout - for now we simply set it 2s before
|
|
||||||
// the deadline
|
|
||||||
// The former gives us periodicity if the watch breaks due to unexpected
|
|
||||||
// conditions, the later ensures that on timeout the watcher is as close to
|
|
||||||
// now as possible - this covers 99% of cases.
|
|
||||||
heartbeatTime := now.Add(bookmarkHeartbeatFrequency)
|
|
||||||
if c.deadline.IsZero() {
|
if c.deadline.IsZero() {
|
||||||
return heartbeatTime
|
return c.deadline, false
|
||||||
}
|
}
|
||||||
if pretimeoutTime := c.deadline.Add(-2 * time.Second); pretimeoutTime.Before(heartbeatTime) {
|
return c.deadline.Add(-2 * time.Second), true
|
||||||
return pretimeoutTime
|
|
||||||
}
|
|
||||||
return heartbeatTime
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func getEventObject(object runtime.Object) runtime.Object {
|
func getEventObject(object runtime.Object) runtime.Object {
|
||||||
|
Loading…
Reference in New Issue
Block a user