From c16c96a7f1b4751c9b080b9913d9190aa1e00a3d Mon Sep 17 00:00:00 2001 From: wojtekt Date: Wed, 6 May 2020 19:37:57 +0200 Subject: [PATCH] Request for bookmarks in RetryWatcher Kubernetes-commit: 7a65760f6e914e5421b443980831b2965c6954c7 --- tools/watch/retrywatcher.go | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/tools/watch/retrywatcher.go b/tools/watch/retrywatcher.go index edf28d16..cfc0d5ff 100644 --- a/tools/watch/retrywatcher.go +++ b/tools/watch/retrywatcher.go @@ -101,7 +101,8 @@ func (rw *RetryWatcher) send(event watch.Event) bool { // If it is not done the second return value holds the time to wait before calling it again. func (rw *RetryWatcher) doReceive() (bool, time.Duration) { watcher, err := rw.watcherClient.Watch(metav1.ListOptions{ - ResourceVersion: rw.lastResourceVersion, + ResourceVersion: rw.lastResourceVersion, + AllowWatchBookmarks: true, }) // We are very unlikely to hit EOF here since we are just establishing the call, // but it may happen that the apiserver is just shutting down (e.g. being restarted) @@ -174,10 +175,12 @@ func (rw *RetryWatcher) doReceive() (bool, time.Duration) { return true, 0 } - // All is fine; send the event and update lastResourceVersion - ok = rw.send(event) - if !ok { - return true, 0 + // All is fine; send the non-bookmark events and update resource version. + if event.Type != watch.Bookmark { + ok = rw.send(event) + if !ok { + return true, 0 + } } rw.lastResourceVersion = resourceVersion