From 3fab93670b9d32af35284606dbdf5a387951dfc2 Mon Sep 17 00:00:00 2001 From: Lukasz Szaszkiewicz Date: Wed, 11 Jun 2025 13:43:37 +0200 Subject: [PATCH] client-go/gentype: remove watchlist Kubernetes-commit: 2f943293ed80e329141a0b8ab8ce093416c456c7 --- gentype/type.go | 39 --------------------------------------- 1 file changed, 39 deletions(-) diff --git a/gentype/type.go b/gentype/type.go index e6ed6aae..e9f42e14 100644 --- a/gentype/type.go +++ b/gentype/type.go @@ -27,9 +27,6 @@ import ( watch "k8s.io/apimachinery/pkg/watch" rest "k8s.io/client-go/rest" "k8s.io/client-go/util/apply" - "k8s.io/client-go/util/consistencydetector" - "k8s.io/client-go/util/watchlist" - "k8s.io/klog/v2" ) // objectWithMeta matches objects implementing both runtime.Object and metav1.Object. @@ -172,24 +169,6 @@ func (c *Client[T]) Get(ctx context.Context, name string, options metav1.GetOpti // List takes label and field selectors, and returns the list of resources that match those selectors. func (l *alsoLister[T, L]) List(ctx context.Context, opts metav1.ListOptions) (L, error) { - if watchListOptions, hasWatchListOptionsPrepared, watchListOptionsErr := watchlist.PrepareWatchListOptionsFromListOptions(opts); watchListOptionsErr != nil { - klog.Warningf("Failed preparing watchlist options for $.type|resource$, falling back to the standard LIST semantics, err = %v", watchListOptionsErr) - } else if hasWatchListOptionsPrepared { - result, err := l.watchList(ctx, watchListOptions) - if err == nil { - consistencydetector.CheckWatchListFromCacheDataConsistencyIfRequested(ctx, "watchlist request for "+l.client.resource, l.list, opts, result) - return result, nil - } - klog.Warningf("The watchlist request for %s ended with an error, falling back to the standard LIST semantics, err = %v", l.client.resource, err) - } - result, err := l.list(ctx, opts) - if err == nil { - consistencydetector.CheckListFromCacheDataConsistencyIfRequested(ctx, "list request for "+l.client.resource, l.list, opts, result) - } - return result, err -} - -func (l *alsoLister[T, L]) list(ctx context.Context, opts metav1.ListOptions) (L, error) { list := l.newList() var timeout time.Duration if opts.TimeoutSeconds != nil { @@ -206,24 +185,6 @@ func (l *alsoLister[T, L]) list(ctx context.Context, opts metav1.ListOptions) (L return list, err } -// watchList establishes a watch stream with the server and returns the list of resources. -func (l *alsoLister[T, L]) watchList(ctx context.Context, opts metav1.ListOptions) (result L, err error) { - var timeout time.Duration - if opts.TimeoutSeconds != nil { - timeout = time.Duration(*opts.TimeoutSeconds) * time.Second - } - result = l.newList() - err = l.client.client.Get(). - UseProtobufAsDefaultIfPreferred(l.client.prefersProtobuf). - NamespaceIfScoped(l.client.namespace, l.client.namespace != ""). - Resource(l.client.resource). - VersionedParams(&opts, l.client.parameterCodec). - Timeout(timeout). - WatchList(ctx). - Into(result) - return -} - // Watch returns a watch.Interface that watches the requested resources. func (c *Client[T]) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { var timeout time.Duration