Skip to content

Commit c2fc338

Browse files
authored
Merge pull request kubernetes#125667 from p0lyn0mial/upstream-watchlist-off-when-progress-notification-disabled
cacher: returns an error when watch list was requested and storage.RequestWatchProgress is disabled
2 parents 59673f0 + cb8cbc6 commit c2fc338

File tree

1 file changed

+11
-1
lines changed
  • staging/src/k8s.io/apiserver/pkg/storage/cacher

1 file changed

+11
-1
lines changed

staging/src/k8s.io/apiserver/pkg/storage/cacher/cacher.go

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -586,6 +586,12 @@ func (c *Cacher) Watch(ctx context.Context, key string, opts storage.ListOptions
586586
// watchers on our watcher having a processing hiccup
587587
chanSize := c.watchCache.suggestedWatchChannelSize(c.indexedTrigger != nil, triggerSupported)
588588

589+
// client-go is going to fall back to a standard LIST on any error
590+
// returned for watch-list requests
591+
if isListWatchRequest(opts) && !etcdfeature.DefaultFeatureSupportChecker.Supports(storage.RequestWatchProgress) {
592+
return newErrWatcher(fmt.Errorf("a watch stream was requested by the client but the required storage feature %s is disabled", storage.RequestWatchProgress)), nil
593+
}
594+
589595
// Determine the ResourceVersion to which the watch cache must be synchronized
590596
requiredResourceVersion, err := c.getWatchCacheResourceVersion(ctx, requestedWatchRV, opts)
591597
if err != nil {
@@ -1339,7 +1345,7 @@ func (c *Cacher) LastSyncResourceVersion() (uint64, error) {
13391345
//
13401346
// The returned function must be called under the watchCache lock.
13411347
func (c *Cacher) getBookmarkAfterResourceVersionLockedFunc(parsedResourceVersion, requiredResourceVersion uint64, opts storage.ListOptions) (func() uint64, error) {
1342-
if opts.SendInitialEvents == nil || !*opts.SendInitialEvents || !opts.Predicate.AllowWatchBookmarks {
1348+
if !isListWatchRequest(opts) {
13431349
return func() uint64 { return 0 }, nil
13441350
}
13451351

@@ -1354,6 +1360,10 @@ func (c *Cacher) getBookmarkAfterResourceVersionLockedFunc(parsedResourceVersion
13541360
}
13551361
}
13561362

1363+
func isListWatchRequest(opts storage.ListOptions) bool {
1364+
return opts.SendInitialEvents != nil && *opts.SendInitialEvents && opts.Predicate.AllowWatchBookmarks
1365+
}
1366+
13571367
// getWatchCacheResourceVersion returns a ResourceVersion to which the watch cache must be synchronized to
13581368
//
13591369
// Depending on the input parameters, the semantics of the returned ResourceVersion are:

0 commit comments

Comments
 (0)