Skip to content

Commit cb8cbc6

Browse files
committed
cacher: returns an error when watch list was requested and storage.RequestWatchProgress is disabled
1 parent fb7bbd2 commit cb8cbc6

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
@@ -578,6 +578,12 @@ func (c *Cacher) Watch(ctx context.Context, key string, opts storage.ListOptions
578578
// watchers on our watcher having a processing hiccup
579579
chanSize := c.watchCache.suggestedWatchChannelSize(c.indexedTrigger != nil, triggerSupported)
580580

581+
// client-go is going to fall back to a standard LIST on any error
582+
// returned for watch-list requests
583+
if isListWatchRequest(opts) && !etcdfeature.DefaultFeatureSupportChecker.Supports(storage.RequestWatchProgress) {
584+
return newErrWatcher(fmt.Errorf("a watch stream was requested by the client but the required storage feature %s is disabled", storage.RequestWatchProgress)), nil
585+
}
586+
581587
// Determine the ResourceVersion to which the watch cache must be synchronized
582588
requiredResourceVersion, err := c.getWatchCacheResourceVersion(ctx, requestedWatchRV, opts)
583589
if err != nil {
@@ -1296,7 +1302,7 @@ func (c *Cacher) LastSyncResourceVersion() (uint64, error) {
12961302
//
12971303
// The returned function must be called under the watchCache lock.
12981304
func (c *Cacher) getBookmarkAfterResourceVersionLockedFunc(parsedResourceVersion, requiredResourceVersion uint64, opts storage.ListOptions) (func() uint64, error) {
1299-
if opts.SendInitialEvents == nil || !*opts.SendInitialEvents || !opts.Predicate.AllowWatchBookmarks {
1305+
if !isListWatchRequest(opts) {
13001306
return func() uint64 { return 0 }, nil
13011307
}
13021308

@@ -1311,6 +1317,10 @@ func (c *Cacher) getBookmarkAfterResourceVersionLockedFunc(parsedResourceVersion
13111317
}
13121318
}
13131319

1320+
func isListWatchRequest(opts storage.ListOptions) bool {
1321+
return opts.SendInitialEvents != nil && *opts.SendInitialEvents && opts.Predicate.AllowWatchBookmarks
1322+
}
1323+
13141324
// getWatchCacheResourceVersion returns a ResourceVersion to which the watch cache must be synchronized to
13151325
//
13161326
// Depending on the input parameters, the semantics of the returned ResourceVersion are:

0 commit comments

Comments
 (0)