From dceabab8382c389d1a68fa29d87769f05d4e1541 Mon Sep 17 00:00:00 2001 From: Lukasz Szaszkiewicz Date: Wed, 24 Apr 2024 12:59:35 +0200 Subject: [PATCH 1/4] client-gen: intro watchList --- .../generators/generator_for_type.go | 93 +++++++++++++------ 1 file changed, 63 insertions(+), 30 deletions(-) diff --git a/staging/src/k8s.io/code-generator/cmd/client-gen/generators/generator_for_type.go b/staging/src/k8s.io/code-generator/cmd/client-gen/generators/generator_for_type.go index 45c6887574a..b9d872bc741 100644 --- a/staging/src/k8s.io/code-generator/cmd/client-gen/generators/generator_for_type.go +++ b/staging/src/k8s.io/code-generator/cmd/client-gen/generators/generator_for_type.go @@ -148,31 +148,34 @@ func (g *genClientForType) GenerateType(c *generator.Context, t *types.Type, w i extendedMethods = append(extendedMethods, extendedMethod) } m := map[string]interface{}{ - "type": t, - "inputType": t, - "resultType": t, - "package": pkg, - "Package": namer.IC(pkg), - "namespaced": !tags.NonNamespaced, - "Group": namer.IC(g.group), - "subresource": false, - "subresourcePath": "", - "GroupGoName": g.groupGoName, - "Version": namer.IC(g.version), - "CreateOptions": c.Universe.Type(types.Name{Package: "k8s.io/apimachinery/pkg/apis/meta/v1", Name: "CreateOptions"}), - "DeleteOptions": c.Universe.Type(types.Name{Package: "k8s.io/apimachinery/pkg/apis/meta/v1", Name: "DeleteOptions"}), - "GetOptions": c.Universe.Type(types.Name{Package: "k8s.io/apimachinery/pkg/apis/meta/v1", Name: "GetOptions"}), - "ListOptions": c.Universe.Type(types.Name{Package: "k8s.io/apimachinery/pkg/apis/meta/v1", Name: "ListOptions"}), - "PatchOptions": c.Universe.Type(types.Name{Package: "k8s.io/apimachinery/pkg/apis/meta/v1", Name: "PatchOptions"}), - "ApplyOptions": c.Universe.Type(types.Name{Package: "k8s.io/apimachinery/pkg/apis/meta/v1", Name: "ApplyOptions"}), - "UpdateOptions": c.Universe.Type(types.Name{Package: "k8s.io/apimachinery/pkg/apis/meta/v1", Name: "UpdateOptions"}), - "PatchType": c.Universe.Type(types.Name{Package: "k8s.io/apimachinery/pkg/types", Name: "PatchType"}), - "ApplyPatchType": c.Universe.Type(types.Name{Package: "k8s.io/apimachinery/pkg/types", Name: "ApplyPatchType"}), - "watchInterface": c.Universe.Type(types.Name{Package: "k8s.io/apimachinery/pkg/watch", Name: "Interface"}), - "RESTClientInterface": c.Universe.Type(types.Name{Package: "k8s.io/client-go/rest", Name: "Interface"}), - "schemeParameterCodec": c.Universe.Variable(types.Name{Package: path.Join(g.clientsetPackage, "scheme"), Name: "ParameterCodec"}), - "jsonMarshal": c.Universe.Type(types.Name{Package: "encoding/json", Name: "Marshal"}), - "CheckListFromCacheDataConsistencyIfRequested": c.Universe.Function(types.Name{Package: "k8s.io/client-go/util/consistencydetector", Name: "CheckListFromCacheDataConsistencyIfRequested"}), + "type": t, + "inputType": t, + "resultType": t, + "package": pkg, + "Package": namer.IC(pkg), + "namespaced": !tags.NonNamespaced, + "Group": namer.IC(g.group), + "subresource": false, + "subresourcePath": "", + "GroupGoName": g.groupGoName, + "Version": namer.IC(g.version), + "CreateOptions": c.Universe.Type(types.Name{Package: "k8s.io/apimachinery/pkg/apis/meta/v1", Name: "CreateOptions"}), + "DeleteOptions": c.Universe.Type(types.Name{Package: "k8s.io/apimachinery/pkg/apis/meta/v1", Name: "DeleteOptions"}), + "GetOptions": c.Universe.Type(types.Name{Package: "k8s.io/apimachinery/pkg/apis/meta/v1", Name: "GetOptions"}), + "ListOptions": c.Universe.Type(types.Name{Package: "k8s.io/apimachinery/pkg/apis/meta/v1", Name: "ListOptions"}), + "PatchOptions": c.Universe.Type(types.Name{Package: "k8s.io/apimachinery/pkg/apis/meta/v1", Name: "PatchOptions"}), + "ApplyOptions": c.Universe.Type(types.Name{Package: "k8s.io/apimachinery/pkg/apis/meta/v1", Name: "ApplyOptions"}), + "UpdateOptions": c.Universe.Type(types.Name{Package: "k8s.io/apimachinery/pkg/apis/meta/v1", Name: "UpdateOptions"}), + "PatchType": c.Universe.Type(types.Name{Package: "k8s.io/apimachinery/pkg/types", Name: "PatchType"}), + "ApplyPatchType": c.Universe.Type(types.Name{Package: "k8s.io/apimachinery/pkg/types", Name: "ApplyPatchType"}), + "watchInterface": c.Universe.Type(types.Name{Package: "k8s.io/apimachinery/pkg/watch", Name: "Interface"}), + "RESTClientInterface": c.Universe.Type(types.Name{Package: "k8s.io/client-go/rest", Name: "Interface"}), + "schemeParameterCodec": c.Universe.Variable(types.Name{Package: path.Join(g.clientsetPackage, "scheme"), Name: "ParameterCodec"}), + "jsonMarshal": c.Universe.Type(types.Name{Package: "encoding/json", Name: "Marshal"}), + "resourceVersionMatchNotOlderThan": c.Universe.Type(types.Name{Package: "k8s.io/apimachinery/pkg/apis/meta/v1", Name: "ResourceVersionMatchNotOlderThan"}), + "CheckListFromCacheDataConsistencyIfRequested": c.Universe.Function(types.Name{Package: "k8s.io/client-go/util/consistencydetector", Name: "CheckListFromCacheDataConsistencyIfRequested"}), + "CheckWatchListFromCacheDataConsistencyIfRequested": c.Universe.Function(types.Name{Package: "k8s.io/client-go/util/consistencydetector", Name: "CheckWatchListFromCacheDataConsistencyIfRequested"}), + "PrepareWatchListOptionsFromListOptions": c.Universe.Function(types.Name{Package: "k8s.io/client-go/util/watchlist", Name: "PrepareWatchListOptionsFromListOptions"}), } if generateApply { @@ -225,6 +228,7 @@ func (g *genClientForType) GenerateType(c *generator.Context, t *types.Type, w i if tags.HasVerb("list") { sw.Do(listTemplate, m) sw.Do(privateListTemplate, m) + sw.Do(watchListTemplate, m) } if tags.HasVerb("watch") { sw.Do(watchTemplate, m) @@ -301,6 +305,7 @@ func (g *genClientForType) GenerateType(c *generator.Context, t *types.Type, w i } else { sw.Do(adjustTemplate(e.VerbName, e.VerbType, listTemplate), m) sw.Do(adjustTemplate(e.VerbName, e.VerbType, privateListTemplate), m) + sw.Do(adjustTemplate(e.VerbName, e.VerbType, watchListTemplate), m) } } @@ -461,13 +466,22 @@ func new$.type|publicPlural$(c *$.GroupGoName$$.Version$Client) *$.type|privateP ` var listTemplate = ` // List takes label and field selectors, and returns the list of $.resultType|publicPlural$ that match those selectors. -func (c *$.type|privatePlural$) List(ctx context.Context, opts $.ListOptions|raw$) (result *$.resultType|raw$List, err error) { - defer func() { +func (c *$.type|privatePlural$) List(ctx context.Context, opts $.ListOptions|raw$) (*$.resultType|raw$List, error) { + if watchListOptions, hasWatchListOptionsPrepared, watchListOptionsErr := $.PrepareWatchListOptionsFromListOptions|raw$(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 := c.watchList(ctx, watchListOptions) if err == nil { - $.CheckListFromCacheDataConsistencyIfRequested|raw$(ctx, "list request for $.type|resource$", c.list, opts, result) + $.CheckWatchListFromCacheDataConsistencyIfRequested|raw$(ctx, "watchlist request for $.type|resource$", c.list, opts, result) + return result, nil } - }() - return c.list(ctx, opts) + klog.Warningf("The watchlist request for $.type|resource$ ended with an error, falling back to the standard LIST semantics, err = %v", err) + } + result, err := c.list(ctx, opts) + if err == nil { + $.CheckListFromCacheDataConsistencyIfRequested|raw$(ctx, "list request for $.type|resource$", c.list, opts, result) + } + return result, err } ` @@ -673,6 +687,25 @@ func (c *$.type|privatePlural$) Watch(ctx context.Context, opts $.ListOptions|ra } ` +var watchListTemplate = ` +// watchList establishes a watch stream with the server and returns the list of $.resultType|publicPlural$ +func (c *$.type|privatePlural$) watchList(ctx context.Context, opts $.ListOptions|raw$) (result *$.resultType|raw$List, err error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil{ + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + result = &$.resultType|raw$List{} + err = c.client.Get(). + $if .namespaced$Namespace(c.ns).$end$ + Resource("$.type|resource$"). + VersionedParams(&opts, $.schemeParameterCodec|raw$). + Timeout(timeout). + WatchList(ctx). + Into(result) + return +} +` + var patchTemplate = ` // Patch applies the patch and returns the patched $.resultType|private$. func (c *$.type|privatePlural$) Patch(ctx context.Context, name string, pt $.PatchType|raw$, data []byte, opts $.PatchOptions|raw$, subresources ...string) (result *$.resultType|raw$, err error) { From 5b76642909b60caf6f51545d836febdc3488be93 Mon Sep 17 00:00:00 2001 From: Lukasz Szaszkiewicz Date: Thu, 13 Jun 2024 10:25:30 +0200 Subject: [PATCH 2/4] e2e/apimachinery/watchlist: test if WatchList is requested by client-go's List method when WatchListClient is enabled --- test/e2e/apimachinery/watchlist.go | 54 +++++++++++++++++++++++++++++- 1 file changed, 53 insertions(+), 1 deletion(-) diff --git a/test/e2e/apimachinery/watchlist.go b/test/e2e/apimachinery/watchlist.go index e5b4ec6abf0..9a6548c5455 100644 --- a/test/e2e/apimachinery/watchlist.go +++ b/test/e2e/apimachinery/watchlist.go @@ -19,11 +19,13 @@ package apimachinery import ( "context" "fmt" + "net/http" "sort" "time" "github.com/google/go-cmp/cmp" "github.com/onsi/ginkgo/v2" + "github.com/onsi/gomega" v1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" @@ -32,7 +34,9 @@ import ( "k8s.io/apimachinery/pkg/watch" utilfeature "k8s.io/apiserver/pkg/util/feature" clientfeatures "k8s.io/client-go/features" + "k8s.io/client-go/kubernetes" "k8s.io/client-go/tools/cache" + "k8s.io/client-go/util/consistencydetector" "k8s.io/component-base/featuregate" featuregatetesting "k8s.io/component-base/featuregate/testing" "k8s.io/kubernetes/test/e2e/feature" @@ -41,7 +45,7 @@ import ( var _ = SIGDescribe("API Streaming (aka. WatchList)", framework.WithSerial(), feature.WatchList, func() { f := framework.NewDefaultFramework("watchlist") - ginkgo.It("should be requested when WatchListClient is enabled", func(ctx context.Context) { + ginkgo.It("should be requested by informers when WatchListClient is enabled", func(ctx context.Context) { featuregatetesting.SetFeatureGateDuringTest(ginkgo.GinkgoTB(), utilfeature.DefaultFeatureGate, featuregate.Feature(clientfeatures.WatchListClient), true) stopCh := make(chan struct{}) defer close(stopCh) @@ -85,8 +89,56 @@ var _ = SIGDescribe("API Streaming (aka. WatchList)", framework.WithSerial(), fe framework.ExpectNoError(err) verifyStore(ctx, f, secretInformer.GetStore()) }) + ginkgo.It("should be requested by client-go's List method when WatchListClient is enabled", func(ctx context.Context) { + featuregatetesting.SetFeatureGateDuringTest(ginkgo.GinkgoTB(), utilfeature.DefaultFeatureGate, featuregate.Feature(clientfeatures.WatchListClient), true) + + ginkgo.By(fmt.Sprintf("Adding 5 secrets to %s namespace", f.Namespace.Name)) + var expectedSecrets []v1.Secret + for i := 1; i <= 5; i++ { + secret, err := f.ClientSet.CoreV1().Secrets(f.Namespace.Name).Create(ctx, newSecret(fmt.Sprintf("secret-%d", i)), metav1.CreateOptions{}) + framework.ExpectNoError(err) + expectedSecrets = append(expectedSecrets, *secret) + } + + var actualRequestsMadeByKubeClient []string + clientConfig := f.ClientConfig() + clientConfig.Wrap(func(rt http.RoundTripper) http.RoundTripper { + return roundTripFunc(func(req *http.Request) (*http.Response, error) { + actualRequestsMadeByKubeClient = append(actualRequestsMadeByKubeClient, req.URL.RawQuery) + return rt.RoundTrip(req) + }) + }) + wrappedKubeClient, err := kubernetes.NewForConfig(clientConfig) + framework.ExpectNoError(err) + + ginkgo.By("Streaming secrets from the server") + secretList, err := wrappedKubeClient.CoreV1().Secrets(f.Namespace.Name).List(ctx, metav1.ListOptions{}) + framework.ExpectNoError(err) + + ginkgo.By("Verifying if the secret list was properly streamed") + streamedSecrets := secretList.Items + sort.Sort(byName(expectedSecrets)) + gomega.Expect(cmp.Equal(expectedSecrets, streamedSecrets)).To(gomega.BeTrueBecause("data received via watchlist must match the added data")) + + ginkgo.By("Verifying if expected requests were sent to the server") + expectedRequestMadeByKubeClient := []string{ + // corresponds to a streaming request made by the kube client to stream the secrets + "allowWatchBookmarks=true&resourceVersionMatch=NotOlderThan&sendInitialEvents=true&watch=true", + } + if consistencydetector.IsDataConsistencyDetectionForWatchListEnabled() { + // corresponds to a standard list request made by the consistency detector build in into the kube client + expectedRequestMadeByKubeClient = append(expectedRequestMadeByKubeClient, fmt.Sprintf("resourceVersion=%s&resourceVersionMatch=Exact", secretList.ResourceVersion)) + } + gomega.Expect(actualRequestsMadeByKubeClient).To(gomega.Equal(expectedRequestMadeByKubeClient)) + }) }) +type roundTripFunc func(req *http.Request) (*http.Response, error) + +func (f roundTripFunc) RoundTrip(req *http.Request) (*http.Response, error) { + return f(req) +} + func verifyStore(ctx context.Context, f *framework.Framework, store cache.Store) { ginkgo.By(fmt.Sprintf("Listing secrets directly from the server from %s namespace", f.Namespace.Name)) expectedSecretsList, err := f.ClientSet.CoreV1().Secrets(f.Namespace.Name).List(ctx, metav1.ListOptions{}) From f62c80f965934eeeb2e028497bede7bcc632995d Mon Sep 17 00:00:00 2001 From: Lukasz Szaszkiewicz Date: Thu, 13 Jun 2024 10:25:56 +0200 Subject: [PATCH 3/4] make update --- .../versioned/typed/cr/v1/example.go | 38 ++++++++++++++++--- .../v1/customresourcedefinition.go | 37 +++++++++++++++--- .../v1beta1/customresourcedefinition.go | 37 +++++++++++++++--- .../v1/mutatingwebhookconfiguration.go | 37 +++++++++++++++--- .../v1/validatingadmissionpolicy.go | 37 +++++++++++++++--- .../v1/validatingadmissionpolicybinding.go | 37 +++++++++++++++--- .../v1/validatingwebhookconfiguration.go | 37 +++++++++++++++--- .../v1alpha1/validatingadmissionpolicy.go | 37 +++++++++++++++--- .../validatingadmissionpolicybinding.go | 37 +++++++++++++++--- .../v1beta1/mutatingwebhookconfiguration.go | 37 +++++++++++++++--- .../v1beta1/validatingadmissionpolicy.go | 37 +++++++++++++++--- .../validatingadmissionpolicybinding.go | 37 +++++++++++++++--- .../v1beta1/validatingwebhookconfiguration.go | 37 +++++++++++++++--- .../v1alpha1/storageversion.go | 37 +++++++++++++++--- .../typed/apps/v1/controllerrevision.go | 38 ++++++++++++++++--- .../kubernetes/typed/apps/v1/daemonset.go | 38 ++++++++++++++++--- .../kubernetes/typed/apps/v1/deployment.go | 38 ++++++++++++++++--- .../kubernetes/typed/apps/v1/replicaset.go | 38 ++++++++++++++++--- .../kubernetes/typed/apps/v1/statefulset.go | 38 ++++++++++++++++--- .../typed/apps/v1beta1/controllerrevision.go | 38 ++++++++++++++++--- .../typed/apps/v1beta1/deployment.go | 38 ++++++++++++++++--- .../typed/apps/v1beta1/statefulset.go | 38 ++++++++++++++++--- .../typed/apps/v1beta2/controllerrevision.go | 38 ++++++++++++++++--- .../typed/apps/v1beta2/daemonset.go | 38 ++++++++++++++++--- .../typed/apps/v1beta2/deployment.go | 38 ++++++++++++++++--- .../typed/apps/v1beta2/replicaset.go | 38 ++++++++++++++++--- .../typed/apps/v1beta2/statefulset.go | 38 ++++++++++++++++--- .../autoscaling/v1/horizontalpodautoscaler.go | 38 ++++++++++++++++--- .../autoscaling/v2/horizontalpodautoscaler.go | 38 ++++++++++++++++--- .../v2beta1/horizontalpodautoscaler.go | 38 ++++++++++++++++--- .../v2beta2/horizontalpodautoscaler.go | 38 ++++++++++++++++--- .../kubernetes/typed/batch/v1/cronjob.go | 38 ++++++++++++++++--- .../kubernetes/typed/batch/v1/job.go | 38 ++++++++++++++++--- .../kubernetes/typed/batch/v1beta1/cronjob.go | 38 ++++++++++++++++--- .../v1/certificatesigningrequest.go | 37 +++++++++++++++--- .../v1alpha1/clustertrustbundle.go | 37 +++++++++++++++--- .../v1beta1/certificatesigningrequest.go | 37 +++++++++++++++--- .../kubernetes/typed/coordination/v1/lease.go | 38 ++++++++++++++++--- .../typed/coordination/v1beta1/lease.go | 38 ++++++++++++++++--- .../typed/core/v1/componentstatus.go | 37 +++++++++++++++--- .../kubernetes/typed/core/v1/configmap.go | 38 ++++++++++++++++--- .../kubernetes/typed/core/v1/endpoints.go | 38 ++++++++++++++++--- .../kubernetes/typed/core/v1/event.go | 38 ++++++++++++++++--- .../kubernetes/typed/core/v1/limitrange.go | 38 ++++++++++++++++--- .../kubernetes/typed/core/v1/namespace.go | 37 +++++++++++++++--- .../kubernetes/typed/core/v1/node.go | 37 +++++++++++++++--- .../typed/core/v1/persistentvolume.go | 37 +++++++++++++++--- .../typed/core/v1/persistentvolumeclaim.go | 38 ++++++++++++++++--- .../client-go/kubernetes/typed/core/v1/pod.go | 38 ++++++++++++++++--- .../kubernetes/typed/core/v1/podtemplate.go | 38 ++++++++++++++++--- .../typed/core/v1/replicationcontroller.go | 38 ++++++++++++++++--- .../kubernetes/typed/core/v1/resourcequota.go | 38 ++++++++++++++++--- .../kubernetes/typed/core/v1/secret.go | 38 ++++++++++++++++--- .../kubernetes/typed/core/v1/service.go | 38 ++++++++++++++++--- .../typed/core/v1/serviceaccount.go | 38 ++++++++++++++++--- .../typed/discovery/v1/endpointslice.go | 38 ++++++++++++++++--- .../typed/discovery/v1beta1/endpointslice.go | 38 ++++++++++++++++--- .../kubernetes/typed/events/v1/event.go | 38 ++++++++++++++++--- .../kubernetes/typed/events/v1beta1/event.go | 38 ++++++++++++++++--- .../typed/extensions/v1beta1/daemonset.go | 38 ++++++++++++++++--- .../typed/extensions/v1beta1/deployment.go | 38 ++++++++++++++++--- .../typed/extensions/v1beta1/ingress.go | 38 ++++++++++++++++--- .../typed/extensions/v1beta1/networkpolicy.go | 38 ++++++++++++++++--- .../typed/extensions/v1beta1/replicaset.go | 38 ++++++++++++++++--- .../typed/flowcontrol/v1/flowschema.go | 37 +++++++++++++++--- .../v1/prioritylevelconfiguration.go | 37 +++++++++++++++--- .../typed/flowcontrol/v1beta1/flowschema.go | 37 +++++++++++++++--- .../v1beta1/prioritylevelconfiguration.go | 37 +++++++++++++++--- .../typed/flowcontrol/v1beta2/flowschema.go | 37 +++++++++++++++--- .../v1beta2/prioritylevelconfiguration.go | 37 +++++++++++++++--- .../typed/flowcontrol/v1beta3/flowschema.go | 37 +++++++++++++++--- .../v1beta3/prioritylevelconfiguration.go | 37 +++++++++++++++--- .../kubernetes/typed/networking/v1/ingress.go | 38 ++++++++++++++++--- .../typed/networking/v1/ingressclass.go | 37 +++++++++++++++--- .../typed/networking/v1/networkpolicy.go | 38 ++++++++++++++++--- .../typed/networking/v1alpha1/ipaddress.go | 37 +++++++++++++++--- .../typed/networking/v1alpha1/servicecidr.go | 37 +++++++++++++++--- .../typed/networking/v1beta1/ingress.go | 38 ++++++++++++++++--- .../typed/networking/v1beta1/ingressclass.go | 37 +++++++++++++++--- .../kubernetes/typed/node/v1/runtimeclass.go | 37 +++++++++++++++--- .../typed/node/v1alpha1/runtimeclass.go | 37 +++++++++++++++--- .../typed/node/v1beta1/runtimeclass.go | 37 +++++++++++++++--- .../typed/policy/v1/poddisruptionbudget.go | 38 ++++++++++++++++--- .../policy/v1beta1/poddisruptionbudget.go | 38 ++++++++++++++++--- .../kubernetes/typed/rbac/v1/clusterrole.go | 37 +++++++++++++++--- .../typed/rbac/v1/clusterrolebinding.go | 37 +++++++++++++++--- .../kubernetes/typed/rbac/v1/role.go | 38 ++++++++++++++++--- .../kubernetes/typed/rbac/v1/rolebinding.go | 38 ++++++++++++++++--- .../typed/rbac/v1alpha1/clusterrole.go | 37 +++++++++++++++--- .../typed/rbac/v1alpha1/clusterrolebinding.go | 37 +++++++++++++++--- .../kubernetes/typed/rbac/v1alpha1/role.go | 38 ++++++++++++++++--- .../typed/rbac/v1alpha1/rolebinding.go | 38 ++++++++++++++++--- .../typed/rbac/v1beta1/clusterrole.go | 37 +++++++++++++++--- .../typed/rbac/v1beta1/clusterrolebinding.go | 37 +++++++++++++++--- .../kubernetes/typed/rbac/v1beta1/role.go | 38 ++++++++++++++++--- .../typed/rbac/v1beta1/rolebinding.go | 38 ++++++++++++++++--- .../resource/v1alpha2/podschedulingcontext.go | 38 ++++++++++++++++--- .../typed/resource/v1alpha2/resourceclaim.go | 38 ++++++++++++++++--- .../v1alpha2/resourceclaimparameters.go | 38 ++++++++++++++++--- .../v1alpha2/resourceclaimtemplate.go | 38 ++++++++++++++++--- .../typed/resource/v1alpha2/resourceclass.go | 37 +++++++++++++++--- .../v1alpha2/resourceclassparameters.go | 38 ++++++++++++++++--- .../typed/resource/v1alpha2/resourceslice.go | 37 +++++++++++++++--- .../typed/scheduling/v1/priorityclass.go | 37 +++++++++++++++--- .../scheduling/v1alpha1/priorityclass.go | 37 +++++++++++++++--- .../typed/scheduling/v1beta1/priorityclass.go | 37 +++++++++++++++--- .../kubernetes/typed/storage/v1/csidriver.go | 37 +++++++++++++++--- .../kubernetes/typed/storage/v1/csinode.go | 37 +++++++++++++++--- .../typed/storage/v1/csistoragecapacity.go | 38 ++++++++++++++++--- .../typed/storage/v1/storageclass.go | 37 +++++++++++++++--- .../typed/storage/v1/volumeattachment.go | 37 +++++++++++++++--- .../storage/v1alpha1/csistoragecapacity.go | 38 ++++++++++++++++--- .../storage/v1alpha1/volumeattachment.go | 37 +++++++++++++++--- .../storage/v1alpha1/volumeattributesclass.go | 37 +++++++++++++++--- .../typed/storage/v1beta1/csidriver.go | 37 +++++++++++++++--- .../typed/storage/v1beta1/csinode.go | 37 +++++++++++++++--- .../storage/v1beta1/csistoragecapacity.go | 38 ++++++++++++++++--- .../typed/storage/v1beta1/storageclass.go | 37 +++++++++++++++--- .../typed/storage/v1beta1/volumeattachment.go | 37 +++++++++++++++--- .../v1alpha1/storageversionmigration.go | 37 +++++++++++++++--- .../typed/example/v1/clustertesttype.go | 37 +++++++++++++++--- .../versioned/typed/example/v1/testtype.go | 38 ++++++++++++++++--- .../typed/example/v1/clustertesttype.go | 37 +++++++++++++++--- .../versioned/typed/example/v1/testtype.go | 38 ++++++++++++++++--- .../versioned/typed/example/v1/testtype.go | 38 ++++++++++++++++--- .../versioned/typed/example2/v1/testtype.go | 38 ++++++++++++++++--- .../typed/example3.io/v1/testtype.go | 38 ++++++++++++++++--- .../typed/example/v1/clustertesttype.go | 37 +++++++++++++++--- .../versioned/typed/example/v1/testtype.go | 38 ++++++++++++++++--- .../versioned/typed/example2/v1/testtype.go | 38 ++++++++++++++++--- .../typed/apiregistration/v1/apiservice.go | 37 +++++++++++++++--- .../apiregistration/v1beta1/apiservice.go | 37 +++++++++++++++--- .../typed/metrics/v1alpha1/nodemetrics.go | 37 +++++++++++++++--- .../typed/metrics/v1alpha1/podmetrics.go | 38 ++++++++++++++++--- .../typed/metrics/v1beta1/nodemetrics.go | 37 +++++++++++++++--- .../typed/metrics/v1beta1/podmetrics.go | 38 ++++++++++++++++--- .../typed/wardle/v1alpha1/fischer.go | 37 +++++++++++++++--- .../typed/wardle/v1alpha1/flunder.go | 38 ++++++++++++++++--- .../versioned/typed/wardle/v1beta1/flunder.go | 38 ++++++++++++++++--- .../typed/samplecontroller/v1alpha1/foo.go | 38 ++++++++++++++++--- 140 files changed, 4555 insertions(+), 700 deletions(-) diff --git a/staging/src/k8s.io/apiextensions-apiserver/examples/client-go/pkg/client/clientset/versioned/typed/cr/v1/example.go b/staging/src/k8s.io/apiextensions-apiserver/examples/client-go/pkg/client/clientset/versioned/typed/cr/v1/example.go index e2d9e88e1c7..775e34a3a1b 100644 --- a/staging/src/k8s.io/apiextensions-apiserver/examples/client-go/pkg/client/clientset/versioned/typed/cr/v1/example.go +++ b/staging/src/k8s.io/apiextensions-apiserver/examples/client-go/pkg/client/clientset/versioned/typed/cr/v1/example.go @@ -32,6 +32,8 @@ import ( watch "k8s.io/apimachinery/pkg/watch" rest "k8s.io/client-go/rest" consistencydetector "k8s.io/client-go/util/consistencydetector" + watchlist "k8s.io/client-go/util/watchlist" + "k8s.io/klog/v2" ) // ExamplesGetter has a method to return a ExampleInterface. @@ -82,13 +84,22 @@ func (c *examples) Get(ctx context.Context, name string, options metav1.GetOptio } // List takes label and field selectors, and returns the list of Examples that match those selectors. -func (c *examples) List(ctx context.Context, opts metav1.ListOptions) (result *v1.ExampleList, err error) { - defer func() { +func (c *examples) List(ctx context.Context, opts metav1.ListOptions) (*v1.ExampleList, error) { + if watchListOptions, hasWatchListOptionsPrepared, watchListOptionsErr := watchlist.PrepareWatchListOptionsFromListOptions(opts); watchListOptionsErr != nil { + klog.Warningf("Failed preparing watchlist options for examples, falling back to the standard LIST semantics, err = %v", watchListOptionsErr) + } else if hasWatchListOptionsPrepared { + result, err := c.watchList(ctx, watchListOptions) if err == nil { - consistencydetector.CheckListFromCacheDataConsistencyIfRequested(ctx, "list request for examples", c.list, opts, result) + consistencydetector.CheckWatchListFromCacheDataConsistencyIfRequested(ctx, "watchlist request for examples", c.list, opts, result) + return result, nil } - }() - return c.list(ctx, opts) + klog.Warningf("The watchlist request for examples ended with an error, falling back to the standard LIST semantics, err = %v", err) + } + result, err := c.list(ctx, opts) + if err == nil { + consistencydetector.CheckListFromCacheDataConsistencyIfRequested(ctx, "list request for examples", c.list, opts, result) + } + return result, err } // list takes label and field selectors, and returns the list of Examples that match those selectors. @@ -108,6 +119,23 @@ func (c *examples) list(ctx context.Context, opts metav1.ListOptions) (result *v return } +// watchList establishes a watch stream with the server and returns the list of Examples +func (c *examples) watchList(ctx context.Context, opts metav1.ListOptions) (result *v1.ExampleList, err error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + result = &v1.ExampleList{} + err = c.client.Get(). + Namespace(c.ns). + Resource("examples"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + WatchList(ctx). + Into(result) + return +} + // Watch returns a watch.Interface that watches the requested examples. func (c *examples) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { var timeout time.Duration diff --git a/staging/src/k8s.io/apiextensions-apiserver/pkg/client/clientset/clientset/typed/apiextensions/v1/customresourcedefinition.go b/staging/src/k8s.io/apiextensions-apiserver/pkg/client/clientset/clientset/typed/apiextensions/v1/customresourcedefinition.go index b69ff56e0d7..ac2f9489daa 100644 --- a/staging/src/k8s.io/apiextensions-apiserver/pkg/client/clientset/clientset/typed/apiextensions/v1/customresourcedefinition.go +++ b/staging/src/k8s.io/apiextensions-apiserver/pkg/client/clientset/clientset/typed/apiextensions/v1/customresourcedefinition.go @@ -32,6 +32,8 @@ import ( watch "k8s.io/apimachinery/pkg/watch" rest "k8s.io/client-go/rest" consistencydetector "k8s.io/client-go/util/consistencydetector" + watchlist "k8s.io/client-go/util/watchlist" + "k8s.io/klog/v2" ) // CustomResourceDefinitionsGetter has a method to return a CustomResourceDefinitionInterface. @@ -81,13 +83,22 @@ func (c *customResourceDefinitions) Get(ctx context.Context, name string, option } // List takes label and field selectors, and returns the list of CustomResourceDefinitions that match those selectors. -func (c *customResourceDefinitions) List(ctx context.Context, opts metav1.ListOptions) (result *v1.CustomResourceDefinitionList, err error) { - defer func() { +func (c *customResourceDefinitions) List(ctx context.Context, opts metav1.ListOptions) (*v1.CustomResourceDefinitionList, error) { + if watchListOptions, hasWatchListOptionsPrepared, watchListOptionsErr := watchlist.PrepareWatchListOptionsFromListOptions(opts); watchListOptionsErr != nil { + klog.Warningf("Failed preparing watchlist options for customresourcedefinitions, falling back to the standard LIST semantics, err = %v", watchListOptionsErr) + } else if hasWatchListOptionsPrepared { + result, err := c.watchList(ctx, watchListOptions) if err == nil { - consistencydetector.CheckListFromCacheDataConsistencyIfRequested(ctx, "list request for customresourcedefinitions", c.list, opts, result) + consistencydetector.CheckWatchListFromCacheDataConsistencyIfRequested(ctx, "watchlist request for customresourcedefinitions", c.list, opts, result) + return result, nil } - }() - return c.list(ctx, opts) + klog.Warningf("The watchlist request for customresourcedefinitions ended with an error, falling back to the standard LIST semantics, err = %v", err) + } + result, err := c.list(ctx, opts) + if err == nil { + consistencydetector.CheckListFromCacheDataConsistencyIfRequested(ctx, "list request for customresourcedefinitions", c.list, opts, result) + } + return result, err } // list takes label and field selectors, and returns the list of CustomResourceDefinitions that match those selectors. @@ -106,6 +117,22 @@ func (c *customResourceDefinitions) list(ctx context.Context, opts metav1.ListOp return } +// watchList establishes a watch stream with the server and returns the list of CustomResourceDefinitions +func (c *customResourceDefinitions) watchList(ctx context.Context, opts metav1.ListOptions) (result *v1.CustomResourceDefinitionList, err error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + result = &v1.CustomResourceDefinitionList{} + err = c.client.Get(). + Resource("customresourcedefinitions"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + WatchList(ctx). + Into(result) + return +} + // Watch returns a watch.Interface that watches the requested customResourceDefinitions. func (c *customResourceDefinitions) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { var timeout time.Duration diff --git a/staging/src/k8s.io/apiextensions-apiserver/pkg/client/clientset/clientset/typed/apiextensions/v1beta1/customresourcedefinition.go b/staging/src/k8s.io/apiextensions-apiserver/pkg/client/clientset/clientset/typed/apiextensions/v1beta1/customresourcedefinition.go index a4f1cbd67dc..2682b629757 100644 --- a/staging/src/k8s.io/apiextensions-apiserver/pkg/client/clientset/clientset/typed/apiextensions/v1beta1/customresourcedefinition.go +++ b/staging/src/k8s.io/apiextensions-apiserver/pkg/client/clientset/clientset/typed/apiextensions/v1beta1/customresourcedefinition.go @@ -32,6 +32,8 @@ import ( watch "k8s.io/apimachinery/pkg/watch" rest "k8s.io/client-go/rest" consistencydetector "k8s.io/client-go/util/consistencydetector" + watchlist "k8s.io/client-go/util/watchlist" + "k8s.io/klog/v2" ) // CustomResourceDefinitionsGetter has a method to return a CustomResourceDefinitionInterface. @@ -81,13 +83,22 @@ func (c *customResourceDefinitions) Get(ctx context.Context, name string, option } // List takes label and field selectors, and returns the list of CustomResourceDefinitions that match those selectors. -func (c *customResourceDefinitions) List(ctx context.Context, opts v1.ListOptions) (result *v1beta1.CustomResourceDefinitionList, err error) { - defer func() { +func (c *customResourceDefinitions) List(ctx context.Context, opts v1.ListOptions) (*v1beta1.CustomResourceDefinitionList, error) { + if watchListOptions, hasWatchListOptionsPrepared, watchListOptionsErr := watchlist.PrepareWatchListOptionsFromListOptions(opts); watchListOptionsErr != nil { + klog.Warningf("Failed preparing watchlist options for customresourcedefinitions, falling back to the standard LIST semantics, err = %v", watchListOptionsErr) + } else if hasWatchListOptionsPrepared { + result, err := c.watchList(ctx, watchListOptions) if err == nil { - consistencydetector.CheckListFromCacheDataConsistencyIfRequested(ctx, "list request for customresourcedefinitions", c.list, opts, result) + consistencydetector.CheckWatchListFromCacheDataConsistencyIfRequested(ctx, "watchlist request for customresourcedefinitions", c.list, opts, result) + return result, nil } - }() - return c.list(ctx, opts) + klog.Warningf("The watchlist request for customresourcedefinitions ended with an error, falling back to the standard LIST semantics, err = %v", err) + } + result, err := c.list(ctx, opts) + if err == nil { + consistencydetector.CheckListFromCacheDataConsistencyIfRequested(ctx, "list request for customresourcedefinitions", c.list, opts, result) + } + return result, err } // list takes label and field selectors, and returns the list of CustomResourceDefinitions that match those selectors. @@ -106,6 +117,22 @@ func (c *customResourceDefinitions) list(ctx context.Context, opts v1.ListOption return } +// watchList establishes a watch stream with the server and returns the list of CustomResourceDefinitions +func (c *customResourceDefinitions) watchList(ctx context.Context, opts v1.ListOptions) (result *v1beta1.CustomResourceDefinitionList, err error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + result = &v1beta1.CustomResourceDefinitionList{} + err = c.client.Get(). + Resource("customresourcedefinitions"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + WatchList(ctx). + Into(result) + return +} + // Watch returns a watch.Interface that watches the requested customResourceDefinitions. func (c *customResourceDefinitions) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { var timeout time.Duration diff --git a/staging/src/k8s.io/client-go/kubernetes/typed/admissionregistration/v1/mutatingwebhookconfiguration.go b/staging/src/k8s.io/client-go/kubernetes/typed/admissionregistration/v1/mutatingwebhookconfiguration.go index 93eb62aa803..4a503068480 100644 --- a/staging/src/k8s.io/client-go/kubernetes/typed/admissionregistration/v1/mutatingwebhookconfiguration.go +++ b/staging/src/k8s.io/client-go/kubernetes/typed/admissionregistration/v1/mutatingwebhookconfiguration.go @@ -32,6 +32,8 @@ import ( scheme "k8s.io/client-go/kubernetes/scheme" rest "k8s.io/client-go/rest" consistencydetector "k8s.io/client-go/util/consistencydetector" + watchlist "k8s.io/client-go/util/watchlist" + "k8s.io/klog/v2" ) // MutatingWebhookConfigurationsGetter has a method to return a MutatingWebhookConfigurationInterface. @@ -79,13 +81,22 @@ func (c *mutatingWebhookConfigurations) Get(ctx context.Context, name string, op } // List takes label and field selectors, and returns the list of MutatingWebhookConfigurations that match those selectors. -func (c *mutatingWebhookConfigurations) List(ctx context.Context, opts metav1.ListOptions) (result *v1.MutatingWebhookConfigurationList, err error) { - defer func() { +func (c *mutatingWebhookConfigurations) List(ctx context.Context, opts metav1.ListOptions) (*v1.MutatingWebhookConfigurationList, error) { + if watchListOptions, hasWatchListOptionsPrepared, watchListOptionsErr := watchlist.PrepareWatchListOptionsFromListOptions(opts); watchListOptionsErr != nil { + klog.Warningf("Failed preparing watchlist options for mutatingwebhookconfigurations, falling back to the standard LIST semantics, err = %v", watchListOptionsErr) + } else if hasWatchListOptionsPrepared { + result, err := c.watchList(ctx, watchListOptions) if err == nil { - consistencydetector.CheckListFromCacheDataConsistencyIfRequested(ctx, "list request for mutatingwebhookconfigurations", c.list, opts, result) + consistencydetector.CheckWatchListFromCacheDataConsistencyIfRequested(ctx, "watchlist request for mutatingwebhookconfigurations", c.list, opts, result) + return result, nil } - }() - return c.list(ctx, opts) + klog.Warningf("The watchlist request for mutatingwebhookconfigurations ended with an error, falling back to the standard LIST semantics, err = %v", err) + } + result, err := c.list(ctx, opts) + if err == nil { + consistencydetector.CheckListFromCacheDataConsistencyIfRequested(ctx, "list request for mutatingwebhookconfigurations", c.list, opts, result) + } + return result, err } // list takes label and field selectors, and returns the list of MutatingWebhookConfigurations that match those selectors. @@ -104,6 +115,22 @@ func (c *mutatingWebhookConfigurations) list(ctx context.Context, opts metav1.Li return } +// watchList establishes a watch stream with the server and returns the list of MutatingWebhookConfigurations +func (c *mutatingWebhookConfigurations) watchList(ctx context.Context, opts metav1.ListOptions) (result *v1.MutatingWebhookConfigurationList, err error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + result = &v1.MutatingWebhookConfigurationList{} + err = c.client.Get(). + Resource("mutatingwebhookconfigurations"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + WatchList(ctx). + Into(result) + return +} + // Watch returns a watch.Interface that watches the requested mutatingWebhookConfigurations. func (c *mutatingWebhookConfigurations) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { var timeout time.Duration diff --git a/staging/src/k8s.io/client-go/kubernetes/typed/admissionregistration/v1/validatingadmissionpolicy.go b/staging/src/k8s.io/client-go/kubernetes/typed/admissionregistration/v1/validatingadmissionpolicy.go index 9bd895051d8..33260641acc 100644 --- a/staging/src/k8s.io/client-go/kubernetes/typed/admissionregistration/v1/validatingadmissionpolicy.go +++ b/staging/src/k8s.io/client-go/kubernetes/typed/admissionregistration/v1/validatingadmissionpolicy.go @@ -32,6 +32,8 @@ import ( scheme "k8s.io/client-go/kubernetes/scheme" rest "k8s.io/client-go/rest" consistencydetector "k8s.io/client-go/util/consistencydetector" + watchlist "k8s.io/client-go/util/watchlist" + "k8s.io/klog/v2" ) // ValidatingAdmissionPoliciesGetter has a method to return a ValidatingAdmissionPolicyInterface. @@ -81,13 +83,22 @@ func (c *validatingAdmissionPolicies) Get(ctx context.Context, name string, opti } // List takes label and field selectors, and returns the list of ValidatingAdmissionPolicies that match those selectors. -func (c *validatingAdmissionPolicies) List(ctx context.Context, opts metav1.ListOptions) (result *v1.ValidatingAdmissionPolicyList, err error) { - defer func() { +func (c *validatingAdmissionPolicies) List(ctx context.Context, opts metav1.ListOptions) (*v1.ValidatingAdmissionPolicyList, error) { + if watchListOptions, hasWatchListOptionsPrepared, watchListOptionsErr := watchlist.PrepareWatchListOptionsFromListOptions(opts); watchListOptionsErr != nil { + klog.Warningf("Failed preparing watchlist options for validatingadmissionpolicies, falling back to the standard LIST semantics, err = %v", watchListOptionsErr) + } else if hasWatchListOptionsPrepared { + result, err := c.watchList(ctx, watchListOptions) if err == nil { - consistencydetector.CheckListFromCacheDataConsistencyIfRequested(ctx, "list request for validatingadmissionpolicies", c.list, opts, result) + consistencydetector.CheckWatchListFromCacheDataConsistencyIfRequested(ctx, "watchlist request for validatingadmissionpolicies", c.list, opts, result) + return result, nil } - }() - return c.list(ctx, opts) + klog.Warningf("The watchlist request for validatingadmissionpolicies ended with an error, falling back to the standard LIST semantics, err = %v", err) + } + result, err := c.list(ctx, opts) + if err == nil { + consistencydetector.CheckListFromCacheDataConsistencyIfRequested(ctx, "list request for validatingadmissionpolicies", c.list, opts, result) + } + return result, err } // list takes label and field selectors, and returns the list of ValidatingAdmissionPolicies that match those selectors. @@ -106,6 +117,22 @@ func (c *validatingAdmissionPolicies) list(ctx context.Context, opts metav1.List return } +// watchList establishes a watch stream with the server and returns the list of ValidatingAdmissionPolicies +func (c *validatingAdmissionPolicies) watchList(ctx context.Context, opts metav1.ListOptions) (result *v1.ValidatingAdmissionPolicyList, err error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + result = &v1.ValidatingAdmissionPolicyList{} + err = c.client.Get(). + Resource("validatingadmissionpolicies"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + WatchList(ctx). + Into(result) + return +} + // Watch returns a watch.Interface that watches the requested validatingAdmissionPolicies. func (c *validatingAdmissionPolicies) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { var timeout time.Duration diff --git a/staging/src/k8s.io/client-go/kubernetes/typed/admissionregistration/v1/validatingadmissionpolicybinding.go b/staging/src/k8s.io/client-go/kubernetes/typed/admissionregistration/v1/validatingadmissionpolicybinding.go index 872bacc6504..eac9f604e2a 100644 --- a/staging/src/k8s.io/client-go/kubernetes/typed/admissionregistration/v1/validatingadmissionpolicybinding.go +++ b/staging/src/k8s.io/client-go/kubernetes/typed/admissionregistration/v1/validatingadmissionpolicybinding.go @@ -32,6 +32,8 @@ import ( scheme "k8s.io/client-go/kubernetes/scheme" rest "k8s.io/client-go/rest" consistencydetector "k8s.io/client-go/util/consistencydetector" + watchlist "k8s.io/client-go/util/watchlist" + "k8s.io/klog/v2" ) // ValidatingAdmissionPolicyBindingsGetter has a method to return a ValidatingAdmissionPolicyBindingInterface. @@ -79,13 +81,22 @@ func (c *validatingAdmissionPolicyBindings) Get(ctx context.Context, name string } // List takes label and field selectors, and returns the list of ValidatingAdmissionPolicyBindings that match those selectors. -func (c *validatingAdmissionPolicyBindings) List(ctx context.Context, opts metav1.ListOptions) (result *v1.ValidatingAdmissionPolicyBindingList, err error) { - defer func() { +func (c *validatingAdmissionPolicyBindings) List(ctx context.Context, opts metav1.ListOptions) (*v1.ValidatingAdmissionPolicyBindingList, error) { + if watchListOptions, hasWatchListOptionsPrepared, watchListOptionsErr := watchlist.PrepareWatchListOptionsFromListOptions(opts); watchListOptionsErr != nil { + klog.Warningf("Failed preparing watchlist options for validatingadmissionpolicybindings, falling back to the standard LIST semantics, err = %v", watchListOptionsErr) + } else if hasWatchListOptionsPrepared { + result, err := c.watchList(ctx, watchListOptions) if err == nil { - consistencydetector.CheckListFromCacheDataConsistencyIfRequested(ctx, "list request for validatingadmissionpolicybindings", c.list, opts, result) + consistencydetector.CheckWatchListFromCacheDataConsistencyIfRequested(ctx, "watchlist request for validatingadmissionpolicybindings", c.list, opts, result) + return result, nil } - }() - return c.list(ctx, opts) + klog.Warningf("The watchlist request for validatingadmissionpolicybindings ended with an error, falling back to the standard LIST semantics, err = %v", err) + } + result, err := c.list(ctx, opts) + if err == nil { + consistencydetector.CheckListFromCacheDataConsistencyIfRequested(ctx, "list request for validatingadmissionpolicybindings", c.list, opts, result) + } + return result, err } // list takes label and field selectors, and returns the list of ValidatingAdmissionPolicyBindings that match those selectors. @@ -104,6 +115,22 @@ func (c *validatingAdmissionPolicyBindings) list(ctx context.Context, opts metav return } +// watchList establishes a watch stream with the server and returns the list of ValidatingAdmissionPolicyBindings +func (c *validatingAdmissionPolicyBindings) watchList(ctx context.Context, opts metav1.ListOptions) (result *v1.ValidatingAdmissionPolicyBindingList, err error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + result = &v1.ValidatingAdmissionPolicyBindingList{} + err = c.client.Get(). + Resource("validatingadmissionpolicybindings"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + WatchList(ctx). + Into(result) + return +} + // Watch returns a watch.Interface that watches the requested validatingAdmissionPolicyBindings. func (c *validatingAdmissionPolicyBindings) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { var timeout time.Duration diff --git a/staging/src/k8s.io/client-go/kubernetes/typed/admissionregistration/v1/validatingwebhookconfiguration.go b/staging/src/k8s.io/client-go/kubernetes/typed/admissionregistration/v1/validatingwebhookconfiguration.go index 585dc22deac..eb7df7efec9 100644 --- a/staging/src/k8s.io/client-go/kubernetes/typed/admissionregistration/v1/validatingwebhookconfiguration.go +++ b/staging/src/k8s.io/client-go/kubernetes/typed/admissionregistration/v1/validatingwebhookconfiguration.go @@ -32,6 +32,8 @@ import ( scheme "k8s.io/client-go/kubernetes/scheme" rest "k8s.io/client-go/rest" consistencydetector "k8s.io/client-go/util/consistencydetector" + watchlist "k8s.io/client-go/util/watchlist" + "k8s.io/klog/v2" ) // ValidatingWebhookConfigurationsGetter has a method to return a ValidatingWebhookConfigurationInterface. @@ -79,13 +81,22 @@ func (c *validatingWebhookConfigurations) Get(ctx context.Context, name string, } // List takes label and field selectors, and returns the list of ValidatingWebhookConfigurations that match those selectors. -func (c *validatingWebhookConfigurations) List(ctx context.Context, opts metav1.ListOptions) (result *v1.ValidatingWebhookConfigurationList, err error) { - defer func() { +func (c *validatingWebhookConfigurations) List(ctx context.Context, opts metav1.ListOptions) (*v1.ValidatingWebhookConfigurationList, error) { + if watchListOptions, hasWatchListOptionsPrepared, watchListOptionsErr := watchlist.PrepareWatchListOptionsFromListOptions(opts); watchListOptionsErr != nil { + klog.Warningf("Failed preparing watchlist options for validatingwebhookconfigurations, falling back to the standard LIST semantics, err = %v", watchListOptionsErr) + } else if hasWatchListOptionsPrepared { + result, err := c.watchList(ctx, watchListOptions) if err == nil { - consistencydetector.CheckListFromCacheDataConsistencyIfRequested(ctx, "list request for validatingwebhookconfigurations", c.list, opts, result) + consistencydetector.CheckWatchListFromCacheDataConsistencyIfRequested(ctx, "watchlist request for validatingwebhookconfigurations", c.list, opts, result) + return result, nil } - }() - return c.list(ctx, opts) + klog.Warningf("The watchlist request for validatingwebhookconfigurations ended with an error, falling back to the standard LIST semantics, err = %v", err) + } + result, err := c.list(ctx, opts) + if err == nil { + consistencydetector.CheckListFromCacheDataConsistencyIfRequested(ctx, "list request for validatingwebhookconfigurations", c.list, opts, result) + } + return result, err } // list takes label and field selectors, and returns the list of ValidatingWebhookConfigurations that match those selectors. @@ -104,6 +115,22 @@ func (c *validatingWebhookConfigurations) list(ctx context.Context, opts metav1. return } +// watchList establishes a watch stream with the server and returns the list of ValidatingWebhookConfigurations +func (c *validatingWebhookConfigurations) watchList(ctx context.Context, opts metav1.ListOptions) (result *v1.ValidatingWebhookConfigurationList, err error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + result = &v1.ValidatingWebhookConfigurationList{} + err = c.client.Get(). + Resource("validatingwebhookconfigurations"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + WatchList(ctx). + Into(result) + return +} + // Watch returns a watch.Interface that watches the requested validatingWebhookConfigurations. func (c *validatingWebhookConfigurations) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { var timeout time.Duration diff --git a/staging/src/k8s.io/client-go/kubernetes/typed/admissionregistration/v1alpha1/validatingadmissionpolicy.go b/staging/src/k8s.io/client-go/kubernetes/typed/admissionregistration/v1alpha1/validatingadmissionpolicy.go index dafd922379e..7c2e9fd218b 100644 --- a/staging/src/k8s.io/client-go/kubernetes/typed/admissionregistration/v1alpha1/validatingadmissionpolicy.go +++ b/staging/src/k8s.io/client-go/kubernetes/typed/admissionregistration/v1alpha1/validatingadmissionpolicy.go @@ -32,6 +32,8 @@ import ( scheme "k8s.io/client-go/kubernetes/scheme" rest "k8s.io/client-go/rest" consistencydetector "k8s.io/client-go/util/consistencydetector" + watchlist "k8s.io/client-go/util/watchlist" + "k8s.io/klog/v2" ) // ValidatingAdmissionPoliciesGetter has a method to return a ValidatingAdmissionPolicyInterface. @@ -81,13 +83,22 @@ func (c *validatingAdmissionPolicies) Get(ctx context.Context, name string, opti } // List takes label and field selectors, and returns the list of ValidatingAdmissionPolicies that match those selectors. -func (c *validatingAdmissionPolicies) List(ctx context.Context, opts v1.ListOptions) (result *v1alpha1.ValidatingAdmissionPolicyList, err error) { - defer func() { +func (c *validatingAdmissionPolicies) List(ctx context.Context, opts v1.ListOptions) (*v1alpha1.ValidatingAdmissionPolicyList, error) { + if watchListOptions, hasWatchListOptionsPrepared, watchListOptionsErr := watchlist.PrepareWatchListOptionsFromListOptions(opts); watchListOptionsErr != nil { + klog.Warningf("Failed preparing watchlist options for validatingadmissionpolicies, falling back to the standard LIST semantics, err = %v", watchListOptionsErr) + } else if hasWatchListOptionsPrepared { + result, err := c.watchList(ctx, watchListOptions) if err == nil { - consistencydetector.CheckListFromCacheDataConsistencyIfRequested(ctx, "list request for validatingadmissionpolicies", c.list, opts, result) + consistencydetector.CheckWatchListFromCacheDataConsistencyIfRequested(ctx, "watchlist request for validatingadmissionpolicies", c.list, opts, result) + return result, nil } - }() - return c.list(ctx, opts) + klog.Warningf("The watchlist request for validatingadmissionpolicies ended with an error, falling back to the standard LIST semantics, err = %v", err) + } + result, err := c.list(ctx, opts) + if err == nil { + consistencydetector.CheckListFromCacheDataConsistencyIfRequested(ctx, "list request for validatingadmissionpolicies", c.list, opts, result) + } + return result, err } // list takes label and field selectors, and returns the list of ValidatingAdmissionPolicies that match those selectors. @@ -106,6 +117,22 @@ func (c *validatingAdmissionPolicies) list(ctx context.Context, opts v1.ListOpti return } +// watchList establishes a watch stream with the server and returns the list of ValidatingAdmissionPolicies +func (c *validatingAdmissionPolicies) watchList(ctx context.Context, opts v1.ListOptions) (result *v1alpha1.ValidatingAdmissionPolicyList, err error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + result = &v1alpha1.ValidatingAdmissionPolicyList{} + err = c.client.Get(). + Resource("validatingadmissionpolicies"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + WatchList(ctx). + Into(result) + return +} + // Watch returns a watch.Interface that watches the requested validatingAdmissionPolicies. func (c *validatingAdmissionPolicies) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { var timeout time.Duration diff --git a/staging/src/k8s.io/client-go/kubernetes/typed/admissionregistration/v1alpha1/validatingadmissionpolicybinding.go b/staging/src/k8s.io/client-go/kubernetes/typed/admissionregistration/v1alpha1/validatingadmissionpolicybinding.go index c8a6c768b8a..d4e4b83374c 100644 --- a/staging/src/k8s.io/client-go/kubernetes/typed/admissionregistration/v1alpha1/validatingadmissionpolicybinding.go +++ b/staging/src/k8s.io/client-go/kubernetes/typed/admissionregistration/v1alpha1/validatingadmissionpolicybinding.go @@ -32,6 +32,8 @@ import ( scheme "k8s.io/client-go/kubernetes/scheme" rest "k8s.io/client-go/rest" consistencydetector "k8s.io/client-go/util/consistencydetector" + watchlist "k8s.io/client-go/util/watchlist" + "k8s.io/klog/v2" ) // ValidatingAdmissionPolicyBindingsGetter has a method to return a ValidatingAdmissionPolicyBindingInterface. @@ -79,13 +81,22 @@ func (c *validatingAdmissionPolicyBindings) Get(ctx context.Context, name string } // List takes label and field selectors, and returns the list of ValidatingAdmissionPolicyBindings that match those selectors. -func (c *validatingAdmissionPolicyBindings) List(ctx context.Context, opts v1.ListOptions) (result *v1alpha1.ValidatingAdmissionPolicyBindingList, err error) { - defer func() { +func (c *validatingAdmissionPolicyBindings) List(ctx context.Context, opts v1.ListOptions) (*v1alpha1.ValidatingAdmissionPolicyBindingList, error) { + if watchListOptions, hasWatchListOptionsPrepared, watchListOptionsErr := watchlist.PrepareWatchListOptionsFromListOptions(opts); watchListOptionsErr != nil { + klog.Warningf("Failed preparing watchlist options for validatingadmissionpolicybindings, falling back to the standard LIST semantics, err = %v", watchListOptionsErr) + } else if hasWatchListOptionsPrepared { + result, err := c.watchList(ctx, watchListOptions) if err == nil { - consistencydetector.CheckListFromCacheDataConsistencyIfRequested(ctx, "list request for validatingadmissionpolicybindings", c.list, opts, result) + consistencydetector.CheckWatchListFromCacheDataConsistencyIfRequested(ctx, "watchlist request for validatingadmissionpolicybindings", c.list, opts, result) + return result, nil } - }() - return c.list(ctx, opts) + klog.Warningf("The watchlist request for validatingadmissionpolicybindings ended with an error, falling back to the standard LIST semantics, err = %v", err) + } + result, err := c.list(ctx, opts) + if err == nil { + consistencydetector.CheckListFromCacheDataConsistencyIfRequested(ctx, "list request for validatingadmissionpolicybindings", c.list, opts, result) + } + return result, err } // list takes label and field selectors, and returns the list of ValidatingAdmissionPolicyBindings that match those selectors. @@ -104,6 +115,22 @@ func (c *validatingAdmissionPolicyBindings) list(ctx context.Context, opts v1.Li return } +// watchList establishes a watch stream with the server and returns the list of ValidatingAdmissionPolicyBindings +func (c *validatingAdmissionPolicyBindings) watchList(ctx context.Context, opts v1.ListOptions) (result *v1alpha1.ValidatingAdmissionPolicyBindingList, err error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + result = &v1alpha1.ValidatingAdmissionPolicyBindingList{} + err = c.client.Get(). + Resource("validatingadmissionpolicybindings"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + WatchList(ctx). + Into(result) + return +} + // Watch returns a watch.Interface that watches the requested validatingAdmissionPolicyBindings. func (c *validatingAdmissionPolicyBindings) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { var timeout time.Duration diff --git a/staging/src/k8s.io/client-go/kubernetes/typed/admissionregistration/v1beta1/mutatingwebhookconfiguration.go b/staging/src/k8s.io/client-go/kubernetes/typed/admissionregistration/v1beta1/mutatingwebhookconfiguration.go index 8e1833448ca..9ca778b6f7e 100644 --- a/staging/src/k8s.io/client-go/kubernetes/typed/admissionregistration/v1beta1/mutatingwebhookconfiguration.go +++ b/staging/src/k8s.io/client-go/kubernetes/typed/admissionregistration/v1beta1/mutatingwebhookconfiguration.go @@ -32,6 +32,8 @@ import ( scheme "k8s.io/client-go/kubernetes/scheme" rest "k8s.io/client-go/rest" consistencydetector "k8s.io/client-go/util/consistencydetector" + watchlist "k8s.io/client-go/util/watchlist" + "k8s.io/klog/v2" ) // MutatingWebhookConfigurationsGetter has a method to return a MutatingWebhookConfigurationInterface. @@ -79,13 +81,22 @@ func (c *mutatingWebhookConfigurations) Get(ctx context.Context, name string, op } // List takes label and field selectors, and returns the list of MutatingWebhookConfigurations that match those selectors. -func (c *mutatingWebhookConfigurations) List(ctx context.Context, opts v1.ListOptions) (result *v1beta1.MutatingWebhookConfigurationList, err error) { - defer func() { +func (c *mutatingWebhookConfigurations) List(ctx context.Context, opts v1.ListOptions) (*v1beta1.MutatingWebhookConfigurationList, error) { + if watchListOptions, hasWatchListOptionsPrepared, watchListOptionsErr := watchlist.PrepareWatchListOptionsFromListOptions(opts); watchListOptionsErr != nil { + klog.Warningf("Failed preparing watchlist options for mutatingwebhookconfigurations, falling back to the standard LIST semantics, err = %v", watchListOptionsErr) + } else if hasWatchListOptionsPrepared { + result, err := c.watchList(ctx, watchListOptions) if err == nil { - consistencydetector.CheckListFromCacheDataConsistencyIfRequested(ctx, "list request for mutatingwebhookconfigurations", c.list, opts, result) + consistencydetector.CheckWatchListFromCacheDataConsistencyIfRequested(ctx, "watchlist request for mutatingwebhookconfigurations", c.list, opts, result) + return result, nil } - }() - return c.list(ctx, opts) + klog.Warningf("The watchlist request for mutatingwebhookconfigurations ended with an error, falling back to the standard LIST semantics, err = %v", err) + } + result, err := c.list(ctx, opts) + if err == nil { + consistencydetector.CheckListFromCacheDataConsistencyIfRequested(ctx, "list request for mutatingwebhookconfigurations", c.list, opts, result) + } + return result, err } // list takes label and field selectors, and returns the list of MutatingWebhookConfigurations that match those selectors. @@ -104,6 +115,22 @@ func (c *mutatingWebhookConfigurations) list(ctx context.Context, opts v1.ListOp return } +// watchList establishes a watch stream with the server and returns the list of MutatingWebhookConfigurations +func (c *mutatingWebhookConfigurations) watchList(ctx context.Context, opts v1.ListOptions) (result *v1beta1.MutatingWebhookConfigurationList, err error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + result = &v1beta1.MutatingWebhookConfigurationList{} + err = c.client.Get(). + Resource("mutatingwebhookconfigurations"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + WatchList(ctx). + Into(result) + return +} + // Watch returns a watch.Interface that watches the requested mutatingWebhookConfigurations. func (c *mutatingWebhookConfigurations) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { var timeout time.Duration diff --git a/staging/src/k8s.io/client-go/kubernetes/typed/admissionregistration/v1beta1/validatingadmissionpolicy.go b/staging/src/k8s.io/client-go/kubernetes/typed/admissionregistration/v1beta1/validatingadmissionpolicy.go index 2cb47362e80..563e887b26e 100644 --- a/staging/src/k8s.io/client-go/kubernetes/typed/admissionregistration/v1beta1/validatingadmissionpolicy.go +++ b/staging/src/k8s.io/client-go/kubernetes/typed/admissionregistration/v1beta1/validatingadmissionpolicy.go @@ -32,6 +32,8 @@ import ( scheme "k8s.io/client-go/kubernetes/scheme" rest "k8s.io/client-go/rest" consistencydetector "k8s.io/client-go/util/consistencydetector" + watchlist "k8s.io/client-go/util/watchlist" + "k8s.io/klog/v2" ) // ValidatingAdmissionPoliciesGetter has a method to return a ValidatingAdmissionPolicyInterface. @@ -81,13 +83,22 @@ func (c *validatingAdmissionPolicies) Get(ctx context.Context, name string, opti } // List takes label and field selectors, and returns the list of ValidatingAdmissionPolicies that match those selectors. -func (c *validatingAdmissionPolicies) List(ctx context.Context, opts v1.ListOptions) (result *v1beta1.ValidatingAdmissionPolicyList, err error) { - defer func() { +func (c *validatingAdmissionPolicies) List(ctx context.Context, opts v1.ListOptions) (*v1beta1.ValidatingAdmissionPolicyList, error) { + if watchListOptions, hasWatchListOptionsPrepared, watchListOptionsErr := watchlist.PrepareWatchListOptionsFromListOptions(opts); watchListOptionsErr != nil { + klog.Warningf("Failed preparing watchlist options for validatingadmissionpolicies, falling back to the standard LIST semantics, err = %v", watchListOptionsErr) + } else if hasWatchListOptionsPrepared { + result, err := c.watchList(ctx, watchListOptions) if err == nil { - consistencydetector.CheckListFromCacheDataConsistencyIfRequested(ctx, "list request for validatingadmissionpolicies", c.list, opts, result) + consistencydetector.CheckWatchListFromCacheDataConsistencyIfRequested(ctx, "watchlist request for validatingadmissionpolicies", c.list, opts, result) + return result, nil } - }() - return c.list(ctx, opts) + klog.Warningf("The watchlist request for validatingadmissionpolicies ended with an error, falling back to the standard LIST semantics, err = %v", err) + } + result, err := c.list(ctx, opts) + if err == nil { + consistencydetector.CheckListFromCacheDataConsistencyIfRequested(ctx, "list request for validatingadmissionpolicies", c.list, opts, result) + } + return result, err } // list takes label and field selectors, and returns the list of ValidatingAdmissionPolicies that match those selectors. @@ -106,6 +117,22 @@ func (c *validatingAdmissionPolicies) list(ctx context.Context, opts v1.ListOpti return } +// watchList establishes a watch stream with the server and returns the list of ValidatingAdmissionPolicies +func (c *validatingAdmissionPolicies) watchList(ctx context.Context, opts v1.ListOptions) (result *v1beta1.ValidatingAdmissionPolicyList, err error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + result = &v1beta1.ValidatingAdmissionPolicyList{} + err = c.client.Get(). + Resource("validatingadmissionpolicies"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + WatchList(ctx). + Into(result) + return +} + // Watch returns a watch.Interface that watches the requested validatingAdmissionPolicies. func (c *validatingAdmissionPolicies) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { var timeout time.Duration diff --git a/staging/src/k8s.io/client-go/kubernetes/typed/admissionregistration/v1beta1/validatingadmissionpolicybinding.go b/staging/src/k8s.io/client-go/kubernetes/typed/admissionregistration/v1beta1/validatingadmissionpolicybinding.go index 6f05360790f..f7f06218f47 100644 --- a/staging/src/k8s.io/client-go/kubernetes/typed/admissionregistration/v1beta1/validatingadmissionpolicybinding.go +++ b/staging/src/k8s.io/client-go/kubernetes/typed/admissionregistration/v1beta1/validatingadmissionpolicybinding.go @@ -32,6 +32,8 @@ import ( scheme "k8s.io/client-go/kubernetes/scheme" rest "k8s.io/client-go/rest" consistencydetector "k8s.io/client-go/util/consistencydetector" + watchlist "k8s.io/client-go/util/watchlist" + "k8s.io/klog/v2" ) // ValidatingAdmissionPolicyBindingsGetter has a method to return a ValidatingAdmissionPolicyBindingInterface. @@ -79,13 +81,22 @@ func (c *validatingAdmissionPolicyBindings) Get(ctx context.Context, name string } // List takes label and field selectors, and returns the list of ValidatingAdmissionPolicyBindings that match those selectors. -func (c *validatingAdmissionPolicyBindings) List(ctx context.Context, opts v1.ListOptions) (result *v1beta1.ValidatingAdmissionPolicyBindingList, err error) { - defer func() { +func (c *validatingAdmissionPolicyBindings) List(ctx context.Context, opts v1.ListOptions) (*v1beta1.ValidatingAdmissionPolicyBindingList, error) { + if watchListOptions, hasWatchListOptionsPrepared, watchListOptionsErr := watchlist.PrepareWatchListOptionsFromListOptions(opts); watchListOptionsErr != nil { + klog.Warningf("Failed preparing watchlist options for validatingadmissionpolicybindings, falling back to the standard LIST semantics, err = %v", watchListOptionsErr) + } else if hasWatchListOptionsPrepared { + result, err := c.watchList(ctx, watchListOptions) if err == nil { - consistencydetector.CheckListFromCacheDataConsistencyIfRequested(ctx, "list request for validatingadmissionpolicybindings", c.list, opts, result) + consistencydetector.CheckWatchListFromCacheDataConsistencyIfRequested(ctx, "watchlist request for validatingadmissionpolicybindings", c.list, opts, result) + return result, nil } - }() - return c.list(ctx, opts) + klog.Warningf("The watchlist request for validatingadmissionpolicybindings ended with an error, falling back to the standard LIST semantics, err = %v", err) + } + result, err := c.list(ctx, opts) + if err == nil { + consistencydetector.CheckListFromCacheDataConsistencyIfRequested(ctx, "list request for validatingadmissionpolicybindings", c.list, opts, result) + } + return result, err } // list takes label and field selectors, and returns the list of ValidatingAdmissionPolicyBindings that match those selectors. @@ -104,6 +115,22 @@ func (c *validatingAdmissionPolicyBindings) list(ctx context.Context, opts v1.Li return } +// watchList establishes a watch stream with the server and returns the list of ValidatingAdmissionPolicyBindings +func (c *validatingAdmissionPolicyBindings) watchList(ctx context.Context, opts v1.ListOptions) (result *v1beta1.ValidatingAdmissionPolicyBindingList, err error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + result = &v1beta1.ValidatingAdmissionPolicyBindingList{} + err = c.client.Get(). + Resource("validatingadmissionpolicybindings"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + WatchList(ctx). + Into(result) + return +} + // Watch returns a watch.Interface that watches the requested validatingAdmissionPolicyBindings. func (c *validatingAdmissionPolicyBindings) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { var timeout time.Duration diff --git a/staging/src/k8s.io/client-go/kubernetes/typed/admissionregistration/v1beta1/validatingwebhookconfiguration.go b/staging/src/k8s.io/client-go/kubernetes/typed/admissionregistration/v1beta1/validatingwebhookconfiguration.go index 671ec8116ea..d20801a1fff 100644 --- a/staging/src/k8s.io/client-go/kubernetes/typed/admissionregistration/v1beta1/validatingwebhookconfiguration.go +++ b/staging/src/k8s.io/client-go/kubernetes/typed/admissionregistration/v1beta1/validatingwebhookconfiguration.go @@ -32,6 +32,8 @@ import ( scheme "k8s.io/client-go/kubernetes/scheme" rest "k8s.io/client-go/rest" consistencydetector "k8s.io/client-go/util/consistencydetector" + watchlist "k8s.io/client-go/util/watchlist" + "k8s.io/klog/v2" ) // ValidatingWebhookConfigurationsGetter has a method to return a ValidatingWebhookConfigurationInterface. @@ -79,13 +81,22 @@ func (c *validatingWebhookConfigurations) Get(ctx context.Context, name string, } // List takes label and field selectors, and returns the list of ValidatingWebhookConfigurations that match those selectors. -func (c *validatingWebhookConfigurations) List(ctx context.Context, opts v1.ListOptions) (result *v1beta1.ValidatingWebhookConfigurationList, err error) { - defer func() { +func (c *validatingWebhookConfigurations) List(ctx context.Context, opts v1.ListOptions) (*v1beta1.ValidatingWebhookConfigurationList, error) { + if watchListOptions, hasWatchListOptionsPrepared, watchListOptionsErr := watchlist.PrepareWatchListOptionsFromListOptions(opts); watchListOptionsErr != nil { + klog.Warningf("Failed preparing watchlist options for validatingwebhookconfigurations, falling back to the standard LIST semantics, err = %v", watchListOptionsErr) + } else if hasWatchListOptionsPrepared { + result, err := c.watchList(ctx, watchListOptions) if err == nil { - consistencydetector.CheckListFromCacheDataConsistencyIfRequested(ctx, "list request for validatingwebhookconfigurations", c.list, opts, result) + consistencydetector.CheckWatchListFromCacheDataConsistencyIfRequested(ctx, "watchlist request for validatingwebhookconfigurations", c.list, opts, result) + return result, nil } - }() - return c.list(ctx, opts) + klog.Warningf("The watchlist request for validatingwebhookconfigurations ended with an error, falling back to the standard LIST semantics, err = %v", err) + } + result, err := c.list(ctx, opts) + if err == nil { + consistencydetector.CheckListFromCacheDataConsistencyIfRequested(ctx, "list request for validatingwebhookconfigurations", c.list, opts, result) + } + return result, err } // list takes label and field selectors, and returns the list of ValidatingWebhookConfigurations that match those selectors. @@ -104,6 +115,22 @@ func (c *validatingWebhookConfigurations) list(ctx context.Context, opts v1.List return } +// watchList establishes a watch stream with the server and returns the list of ValidatingWebhookConfigurations +func (c *validatingWebhookConfigurations) watchList(ctx context.Context, opts v1.ListOptions) (result *v1beta1.ValidatingWebhookConfigurationList, err error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + result = &v1beta1.ValidatingWebhookConfigurationList{} + err = c.client.Get(). + Resource("validatingwebhookconfigurations"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + WatchList(ctx). + Into(result) + return +} + // Watch returns a watch.Interface that watches the requested validatingWebhookConfigurations. func (c *validatingWebhookConfigurations) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { var timeout time.Duration diff --git a/staging/src/k8s.io/client-go/kubernetes/typed/apiserverinternal/v1alpha1/storageversion.go b/staging/src/k8s.io/client-go/kubernetes/typed/apiserverinternal/v1alpha1/storageversion.go index 7f0d60ce35f..100f486a296 100644 --- a/staging/src/k8s.io/client-go/kubernetes/typed/apiserverinternal/v1alpha1/storageversion.go +++ b/staging/src/k8s.io/client-go/kubernetes/typed/apiserverinternal/v1alpha1/storageversion.go @@ -32,6 +32,8 @@ import ( scheme "k8s.io/client-go/kubernetes/scheme" rest "k8s.io/client-go/rest" consistencydetector "k8s.io/client-go/util/consistencydetector" + watchlist "k8s.io/client-go/util/watchlist" + "k8s.io/klog/v2" ) // StorageVersionsGetter has a method to return a StorageVersionInterface. @@ -81,13 +83,22 @@ func (c *storageVersions) Get(ctx context.Context, name string, options v1.GetOp } // List takes label and field selectors, and returns the list of StorageVersions that match those selectors. -func (c *storageVersions) List(ctx context.Context, opts v1.ListOptions) (result *v1alpha1.StorageVersionList, err error) { - defer func() { +func (c *storageVersions) List(ctx context.Context, opts v1.ListOptions) (*v1alpha1.StorageVersionList, error) { + if watchListOptions, hasWatchListOptionsPrepared, watchListOptionsErr := watchlist.PrepareWatchListOptionsFromListOptions(opts); watchListOptionsErr != nil { + klog.Warningf("Failed preparing watchlist options for storageversions, falling back to the standard LIST semantics, err = %v", watchListOptionsErr) + } else if hasWatchListOptionsPrepared { + result, err := c.watchList(ctx, watchListOptions) if err == nil { - consistencydetector.CheckListFromCacheDataConsistencyIfRequested(ctx, "list request for storageversions", c.list, opts, result) + consistencydetector.CheckWatchListFromCacheDataConsistencyIfRequested(ctx, "watchlist request for storageversions", c.list, opts, result) + return result, nil } - }() - return c.list(ctx, opts) + klog.Warningf("The watchlist request for storageversions ended with an error, falling back to the standard LIST semantics, err = %v", err) + } + result, err := c.list(ctx, opts) + if err == nil { + consistencydetector.CheckListFromCacheDataConsistencyIfRequested(ctx, "list request for storageversions", c.list, opts, result) + } + return result, err } // list takes label and field selectors, and returns the list of StorageVersions that match those selectors. @@ -106,6 +117,22 @@ func (c *storageVersions) list(ctx context.Context, opts v1.ListOptions) (result return } +// watchList establishes a watch stream with the server and returns the list of StorageVersions +func (c *storageVersions) watchList(ctx context.Context, opts v1.ListOptions) (result *v1alpha1.StorageVersionList, err error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + result = &v1alpha1.StorageVersionList{} + err = c.client.Get(). + Resource("storageversions"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + WatchList(ctx). + Into(result) + return +} + // Watch returns a watch.Interface that watches the requested storageVersions. func (c *storageVersions) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { var timeout time.Duration diff --git a/staging/src/k8s.io/client-go/kubernetes/typed/apps/v1/controllerrevision.go b/staging/src/k8s.io/client-go/kubernetes/typed/apps/v1/controllerrevision.go index 6a12cc39827..acf50b58c4c 100644 --- a/staging/src/k8s.io/client-go/kubernetes/typed/apps/v1/controllerrevision.go +++ b/staging/src/k8s.io/client-go/kubernetes/typed/apps/v1/controllerrevision.go @@ -32,6 +32,8 @@ import ( scheme "k8s.io/client-go/kubernetes/scheme" rest "k8s.io/client-go/rest" consistencydetector "k8s.io/client-go/util/consistencydetector" + watchlist "k8s.io/client-go/util/watchlist" + "k8s.io/klog/v2" ) // ControllerRevisionsGetter has a method to return a ControllerRevisionInterface. @@ -82,13 +84,22 @@ func (c *controllerRevisions) Get(ctx context.Context, name string, options meta } // List takes label and field selectors, and returns the list of ControllerRevisions that match those selectors. -func (c *controllerRevisions) List(ctx context.Context, opts metav1.ListOptions) (result *v1.ControllerRevisionList, err error) { - defer func() { +func (c *controllerRevisions) List(ctx context.Context, opts metav1.ListOptions) (*v1.ControllerRevisionList, error) { + if watchListOptions, hasWatchListOptionsPrepared, watchListOptionsErr := watchlist.PrepareWatchListOptionsFromListOptions(opts); watchListOptionsErr != nil { + klog.Warningf("Failed preparing watchlist options for controllerrevisions, falling back to the standard LIST semantics, err = %v", watchListOptionsErr) + } else if hasWatchListOptionsPrepared { + result, err := c.watchList(ctx, watchListOptions) if err == nil { - consistencydetector.CheckListFromCacheDataConsistencyIfRequested(ctx, "list request for controllerrevisions", c.list, opts, result) + consistencydetector.CheckWatchListFromCacheDataConsistencyIfRequested(ctx, "watchlist request for controllerrevisions", c.list, opts, result) + return result, nil } - }() - return c.list(ctx, opts) + klog.Warningf("The watchlist request for controllerrevisions ended with an error, falling back to the standard LIST semantics, err = %v", err) + } + result, err := c.list(ctx, opts) + if err == nil { + consistencydetector.CheckListFromCacheDataConsistencyIfRequested(ctx, "list request for controllerrevisions", c.list, opts, result) + } + return result, err } // list takes label and field selectors, and returns the list of ControllerRevisions that match those selectors. @@ -108,6 +119,23 @@ func (c *controllerRevisions) list(ctx context.Context, opts metav1.ListOptions) return } +// watchList establishes a watch stream with the server and returns the list of ControllerRevisions +func (c *controllerRevisions) watchList(ctx context.Context, opts metav1.ListOptions) (result *v1.ControllerRevisionList, err error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + result = &v1.ControllerRevisionList{} + err = c.client.Get(). + Namespace(c.ns). + Resource("controllerrevisions"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + WatchList(ctx). + Into(result) + return +} + // Watch returns a watch.Interface that watches the requested controllerRevisions. func (c *controllerRevisions) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { var timeout time.Duration diff --git a/staging/src/k8s.io/client-go/kubernetes/typed/apps/v1/daemonset.go b/staging/src/k8s.io/client-go/kubernetes/typed/apps/v1/daemonset.go index 251d98e0bea..60741f088dc 100644 --- a/staging/src/k8s.io/client-go/kubernetes/typed/apps/v1/daemonset.go +++ b/staging/src/k8s.io/client-go/kubernetes/typed/apps/v1/daemonset.go @@ -32,6 +32,8 @@ import ( scheme "k8s.io/client-go/kubernetes/scheme" rest "k8s.io/client-go/rest" consistencydetector "k8s.io/client-go/util/consistencydetector" + watchlist "k8s.io/client-go/util/watchlist" + "k8s.io/klog/v2" ) // DaemonSetsGetter has a method to return a DaemonSetInterface. @@ -84,13 +86,22 @@ func (c *daemonSets) Get(ctx context.Context, name string, options metav1.GetOpt } // List takes label and field selectors, and returns the list of DaemonSets that match those selectors. -func (c *daemonSets) List(ctx context.Context, opts metav1.ListOptions) (result *v1.DaemonSetList, err error) { - defer func() { +func (c *daemonSets) List(ctx context.Context, opts metav1.ListOptions) (*v1.DaemonSetList, error) { + if watchListOptions, hasWatchListOptionsPrepared, watchListOptionsErr := watchlist.PrepareWatchListOptionsFromListOptions(opts); watchListOptionsErr != nil { + klog.Warningf("Failed preparing watchlist options for daemonsets, falling back to the standard LIST semantics, err = %v", watchListOptionsErr) + } else if hasWatchListOptionsPrepared { + result, err := c.watchList(ctx, watchListOptions) if err == nil { - consistencydetector.CheckListFromCacheDataConsistencyIfRequested(ctx, "list request for daemonsets", c.list, opts, result) + consistencydetector.CheckWatchListFromCacheDataConsistencyIfRequested(ctx, "watchlist request for daemonsets", c.list, opts, result) + return result, nil } - }() - return c.list(ctx, opts) + klog.Warningf("The watchlist request for daemonsets ended with an error, falling back to the standard LIST semantics, err = %v", err) + } + result, err := c.list(ctx, opts) + if err == nil { + consistencydetector.CheckListFromCacheDataConsistencyIfRequested(ctx, "list request for daemonsets", c.list, opts, result) + } + return result, err } // list takes label and field selectors, and returns the list of DaemonSets that match those selectors. @@ -110,6 +121,23 @@ func (c *daemonSets) list(ctx context.Context, opts metav1.ListOptions) (result return } +// watchList establishes a watch stream with the server and returns the list of DaemonSets +func (c *daemonSets) watchList(ctx context.Context, opts metav1.ListOptions) (result *v1.DaemonSetList, err error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + result = &v1.DaemonSetList{} + err = c.client.Get(). + Namespace(c.ns). + Resource("daemonsets"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + WatchList(ctx). + Into(result) + return +} + // Watch returns a watch.Interface that watches the requested daemonSets. func (c *daemonSets) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { var timeout time.Duration diff --git a/staging/src/k8s.io/client-go/kubernetes/typed/apps/v1/deployment.go b/staging/src/k8s.io/client-go/kubernetes/typed/apps/v1/deployment.go index c97894f1560..256dd69bb01 100644 --- a/staging/src/k8s.io/client-go/kubernetes/typed/apps/v1/deployment.go +++ b/staging/src/k8s.io/client-go/kubernetes/typed/apps/v1/deployment.go @@ -34,6 +34,8 @@ import ( scheme "k8s.io/client-go/kubernetes/scheme" rest "k8s.io/client-go/rest" consistencydetector "k8s.io/client-go/util/consistencydetector" + watchlist "k8s.io/client-go/util/watchlist" + "k8s.io/klog/v2" ) // DeploymentsGetter has a method to return a DeploymentInterface. @@ -90,13 +92,22 @@ func (c *deployments) Get(ctx context.Context, name string, options metav1.GetOp } // List takes label and field selectors, and returns the list of Deployments that match those selectors. -func (c *deployments) List(ctx context.Context, opts metav1.ListOptions) (result *v1.DeploymentList, err error) { - defer func() { +func (c *deployments) List(ctx context.Context, opts metav1.ListOptions) (*v1.DeploymentList, error) { + if watchListOptions, hasWatchListOptionsPrepared, watchListOptionsErr := watchlist.PrepareWatchListOptionsFromListOptions(opts); watchListOptionsErr != nil { + klog.Warningf("Failed preparing watchlist options for deployments, falling back to the standard LIST semantics, err = %v", watchListOptionsErr) + } else if hasWatchListOptionsPrepared { + result, err := c.watchList(ctx, watchListOptions) if err == nil { - consistencydetector.CheckListFromCacheDataConsistencyIfRequested(ctx, "list request for deployments", c.list, opts, result) + consistencydetector.CheckWatchListFromCacheDataConsistencyIfRequested(ctx, "watchlist request for deployments", c.list, opts, result) + return result, nil } - }() - return c.list(ctx, opts) + klog.Warningf("The watchlist request for deployments ended with an error, falling back to the standard LIST semantics, err = %v", err) + } + result, err := c.list(ctx, opts) + if err == nil { + consistencydetector.CheckListFromCacheDataConsistencyIfRequested(ctx, "list request for deployments", c.list, opts, result) + } + return result, err } // list takes label and field selectors, and returns the list of Deployments that match those selectors. @@ -116,6 +127,23 @@ func (c *deployments) list(ctx context.Context, opts metav1.ListOptions) (result return } +// watchList establishes a watch stream with the server and returns the list of Deployments +func (c *deployments) watchList(ctx context.Context, opts metav1.ListOptions) (result *v1.DeploymentList, err error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + result = &v1.DeploymentList{} + err = c.client.Get(). + Namespace(c.ns). + Resource("deployments"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + WatchList(ctx). + Into(result) + return +} + // Watch returns a watch.Interface that watches the requested deployments. func (c *deployments) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { var timeout time.Duration diff --git a/staging/src/k8s.io/client-go/kubernetes/typed/apps/v1/replicaset.go b/staging/src/k8s.io/client-go/kubernetes/typed/apps/v1/replicaset.go index e28f784f945..f8c6ca8ecbb 100644 --- a/staging/src/k8s.io/client-go/kubernetes/typed/apps/v1/replicaset.go +++ b/staging/src/k8s.io/client-go/kubernetes/typed/apps/v1/replicaset.go @@ -34,6 +34,8 @@ import ( scheme "k8s.io/client-go/kubernetes/scheme" rest "k8s.io/client-go/rest" consistencydetector "k8s.io/client-go/util/consistencydetector" + watchlist "k8s.io/client-go/util/watchlist" + "k8s.io/klog/v2" ) // ReplicaSetsGetter has a method to return a ReplicaSetInterface. @@ -90,13 +92,22 @@ func (c *replicaSets) Get(ctx context.Context, name string, options metav1.GetOp } // List takes label and field selectors, and returns the list of ReplicaSets that match those selectors. -func (c *replicaSets) List(ctx context.Context, opts metav1.ListOptions) (result *v1.ReplicaSetList, err error) { - defer func() { +func (c *replicaSets) List(ctx context.Context, opts metav1.ListOptions) (*v1.ReplicaSetList, error) { + if watchListOptions, hasWatchListOptionsPrepared, watchListOptionsErr := watchlist.PrepareWatchListOptionsFromListOptions(opts); watchListOptionsErr != nil { + klog.Warningf("Failed preparing watchlist options for replicasets, falling back to the standard LIST semantics, err = %v", watchListOptionsErr) + } else if hasWatchListOptionsPrepared { + result, err := c.watchList(ctx, watchListOptions) if err == nil { - consistencydetector.CheckListFromCacheDataConsistencyIfRequested(ctx, "list request for replicasets", c.list, opts, result) + consistencydetector.CheckWatchListFromCacheDataConsistencyIfRequested(ctx, "watchlist request for replicasets", c.list, opts, result) + return result, nil } - }() - return c.list(ctx, opts) + klog.Warningf("The watchlist request for replicasets ended with an error, falling back to the standard LIST semantics, err = %v", err) + } + result, err := c.list(ctx, opts) + if err == nil { + consistencydetector.CheckListFromCacheDataConsistencyIfRequested(ctx, "list request for replicasets", c.list, opts, result) + } + return result, err } // list takes label and field selectors, and returns the list of ReplicaSets that match those selectors. @@ -116,6 +127,23 @@ func (c *replicaSets) list(ctx context.Context, opts metav1.ListOptions) (result return } +// watchList establishes a watch stream with the server and returns the list of ReplicaSets +func (c *replicaSets) watchList(ctx context.Context, opts metav1.ListOptions) (result *v1.ReplicaSetList, err error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + result = &v1.ReplicaSetList{} + err = c.client.Get(). + Namespace(c.ns). + Resource("replicasets"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + WatchList(ctx). + Into(result) + return +} + // Watch returns a watch.Interface that watches the requested replicaSets. func (c *replicaSets) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { var timeout time.Duration diff --git a/staging/src/k8s.io/client-go/kubernetes/typed/apps/v1/statefulset.go b/staging/src/k8s.io/client-go/kubernetes/typed/apps/v1/statefulset.go index 2e94e1a6a00..ed667566b6e 100644 --- a/staging/src/k8s.io/client-go/kubernetes/typed/apps/v1/statefulset.go +++ b/staging/src/k8s.io/client-go/kubernetes/typed/apps/v1/statefulset.go @@ -34,6 +34,8 @@ import ( scheme "k8s.io/client-go/kubernetes/scheme" rest "k8s.io/client-go/rest" consistencydetector "k8s.io/client-go/util/consistencydetector" + watchlist "k8s.io/client-go/util/watchlist" + "k8s.io/klog/v2" ) // StatefulSetsGetter has a method to return a StatefulSetInterface. @@ -90,13 +92,22 @@ func (c *statefulSets) Get(ctx context.Context, name string, options metav1.GetO } // List takes label and field selectors, and returns the list of StatefulSets that match those selectors. -func (c *statefulSets) List(ctx context.Context, opts metav1.ListOptions) (result *v1.StatefulSetList, err error) { - defer func() { +func (c *statefulSets) List(ctx context.Context, opts metav1.ListOptions) (*v1.StatefulSetList, error) { + if watchListOptions, hasWatchListOptionsPrepared, watchListOptionsErr := watchlist.PrepareWatchListOptionsFromListOptions(opts); watchListOptionsErr != nil { + klog.Warningf("Failed preparing watchlist options for statefulsets, falling back to the standard LIST semantics, err = %v", watchListOptionsErr) + } else if hasWatchListOptionsPrepared { + result, err := c.watchList(ctx, watchListOptions) if err == nil { - consistencydetector.CheckListFromCacheDataConsistencyIfRequested(ctx, "list request for statefulsets", c.list, opts, result) + consistencydetector.CheckWatchListFromCacheDataConsistencyIfRequested(ctx, "watchlist request for statefulsets", c.list, opts, result) + return result, nil } - }() - return c.list(ctx, opts) + klog.Warningf("The watchlist request for statefulsets ended with an error, falling back to the standard LIST semantics, err = %v", err) + } + result, err := c.list(ctx, opts) + if err == nil { + consistencydetector.CheckListFromCacheDataConsistencyIfRequested(ctx, "list request for statefulsets", c.list, opts, result) + } + return result, err } // list takes label and field selectors, and returns the list of StatefulSets that match those selectors. @@ -116,6 +127,23 @@ func (c *statefulSets) list(ctx context.Context, opts metav1.ListOptions) (resul return } +// watchList establishes a watch stream with the server and returns the list of StatefulSets +func (c *statefulSets) watchList(ctx context.Context, opts metav1.ListOptions) (result *v1.StatefulSetList, err error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + result = &v1.StatefulSetList{} + err = c.client.Get(). + Namespace(c.ns). + Resource("statefulsets"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + WatchList(ctx). + Into(result) + return +} + // Watch returns a watch.Interface that watches the requested statefulSets. func (c *statefulSets) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { var timeout time.Duration diff --git a/staging/src/k8s.io/client-go/kubernetes/typed/apps/v1beta1/controllerrevision.go b/staging/src/k8s.io/client-go/kubernetes/typed/apps/v1beta1/controllerrevision.go index 044101c9527..efa2e74db79 100644 --- a/staging/src/k8s.io/client-go/kubernetes/typed/apps/v1beta1/controllerrevision.go +++ b/staging/src/k8s.io/client-go/kubernetes/typed/apps/v1beta1/controllerrevision.go @@ -32,6 +32,8 @@ import ( scheme "k8s.io/client-go/kubernetes/scheme" rest "k8s.io/client-go/rest" consistencydetector "k8s.io/client-go/util/consistencydetector" + watchlist "k8s.io/client-go/util/watchlist" + "k8s.io/klog/v2" ) // ControllerRevisionsGetter has a method to return a ControllerRevisionInterface. @@ -82,13 +84,22 @@ func (c *controllerRevisions) Get(ctx context.Context, name string, options v1.G } // List takes label and field selectors, and returns the list of ControllerRevisions that match those selectors. -func (c *controllerRevisions) List(ctx context.Context, opts v1.ListOptions) (result *v1beta1.ControllerRevisionList, err error) { - defer func() { +func (c *controllerRevisions) List(ctx context.Context, opts v1.ListOptions) (*v1beta1.ControllerRevisionList, error) { + if watchListOptions, hasWatchListOptionsPrepared, watchListOptionsErr := watchlist.PrepareWatchListOptionsFromListOptions(opts); watchListOptionsErr != nil { + klog.Warningf("Failed preparing watchlist options for controllerrevisions, falling back to the standard LIST semantics, err = %v", watchListOptionsErr) + } else if hasWatchListOptionsPrepared { + result, err := c.watchList(ctx, watchListOptions) if err == nil { - consistencydetector.CheckListFromCacheDataConsistencyIfRequested(ctx, "list request for controllerrevisions", c.list, opts, result) + consistencydetector.CheckWatchListFromCacheDataConsistencyIfRequested(ctx, "watchlist request for controllerrevisions", c.list, opts, result) + return result, nil } - }() - return c.list(ctx, opts) + klog.Warningf("The watchlist request for controllerrevisions ended with an error, falling back to the standard LIST semantics, err = %v", err) + } + result, err := c.list(ctx, opts) + if err == nil { + consistencydetector.CheckListFromCacheDataConsistencyIfRequested(ctx, "list request for controllerrevisions", c.list, opts, result) + } + return result, err } // list takes label and field selectors, and returns the list of ControllerRevisions that match those selectors. @@ -108,6 +119,23 @@ func (c *controllerRevisions) list(ctx context.Context, opts v1.ListOptions) (re return } +// watchList establishes a watch stream with the server and returns the list of ControllerRevisions +func (c *controllerRevisions) watchList(ctx context.Context, opts v1.ListOptions) (result *v1beta1.ControllerRevisionList, err error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + result = &v1beta1.ControllerRevisionList{} + err = c.client.Get(). + Namespace(c.ns). + Resource("controllerrevisions"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + WatchList(ctx). + Into(result) + return +} + // Watch returns a watch.Interface that watches the requested controllerRevisions. func (c *controllerRevisions) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { var timeout time.Duration diff --git a/staging/src/k8s.io/client-go/kubernetes/typed/apps/v1beta1/deployment.go b/staging/src/k8s.io/client-go/kubernetes/typed/apps/v1beta1/deployment.go index 47edb1c8f24..c46987acc75 100644 --- a/staging/src/k8s.io/client-go/kubernetes/typed/apps/v1beta1/deployment.go +++ b/staging/src/k8s.io/client-go/kubernetes/typed/apps/v1beta1/deployment.go @@ -32,6 +32,8 @@ import ( scheme "k8s.io/client-go/kubernetes/scheme" rest "k8s.io/client-go/rest" consistencydetector "k8s.io/client-go/util/consistencydetector" + watchlist "k8s.io/client-go/util/watchlist" + "k8s.io/klog/v2" ) // DeploymentsGetter has a method to return a DeploymentInterface. @@ -84,13 +86,22 @@ func (c *deployments) Get(ctx context.Context, name string, options v1.GetOption } // List takes label and field selectors, and returns the list of Deployments that match those selectors. -func (c *deployments) List(ctx context.Context, opts v1.ListOptions) (result *v1beta1.DeploymentList, err error) { - defer func() { +func (c *deployments) List(ctx context.Context, opts v1.ListOptions) (*v1beta1.DeploymentList, error) { + if watchListOptions, hasWatchListOptionsPrepared, watchListOptionsErr := watchlist.PrepareWatchListOptionsFromListOptions(opts); watchListOptionsErr != nil { + klog.Warningf("Failed preparing watchlist options for deployments, falling back to the standard LIST semantics, err = %v", watchListOptionsErr) + } else if hasWatchListOptionsPrepared { + result, err := c.watchList(ctx, watchListOptions) if err == nil { - consistencydetector.CheckListFromCacheDataConsistencyIfRequested(ctx, "list request for deployments", c.list, opts, result) + consistencydetector.CheckWatchListFromCacheDataConsistencyIfRequested(ctx, "watchlist request for deployments", c.list, opts, result) + return result, nil } - }() - return c.list(ctx, opts) + klog.Warningf("The watchlist request for deployments ended with an error, falling back to the standard LIST semantics, err = %v", err) + } + result, err := c.list(ctx, opts) + if err == nil { + consistencydetector.CheckListFromCacheDataConsistencyIfRequested(ctx, "list request for deployments", c.list, opts, result) + } + return result, err } // list takes label and field selectors, and returns the list of Deployments that match those selectors. @@ -110,6 +121,23 @@ func (c *deployments) list(ctx context.Context, opts v1.ListOptions) (result *v1 return } +// watchList establishes a watch stream with the server and returns the list of Deployments +func (c *deployments) watchList(ctx context.Context, opts v1.ListOptions) (result *v1beta1.DeploymentList, err error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + result = &v1beta1.DeploymentList{} + err = c.client.Get(). + Namespace(c.ns). + Resource("deployments"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + WatchList(ctx). + Into(result) + return +} + // Watch returns a watch.Interface that watches the requested deployments. func (c *deployments) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { var timeout time.Duration diff --git a/staging/src/k8s.io/client-go/kubernetes/typed/apps/v1beta1/statefulset.go b/staging/src/k8s.io/client-go/kubernetes/typed/apps/v1beta1/statefulset.go index e39d7cf5ecf..bdddacec47c 100644 --- a/staging/src/k8s.io/client-go/kubernetes/typed/apps/v1beta1/statefulset.go +++ b/staging/src/k8s.io/client-go/kubernetes/typed/apps/v1beta1/statefulset.go @@ -32,6 +32,8 @@ import ( scheme "k8s.io/client-go/kubernetes/scheme" rest "k8s.io/client-go/rest" consistencydetector "k8s.io/client-go/util/consistencydetector" + watchlist "k8s.io/client-go/util/watchlist" + "k8s.io/klog/v2" ) // StatefulSetsGetter has a method to return a StatefulSetInterface. @@ -84,13 +86,22 @@ func (c *statefulSets) Get(ctx context.Context, name string, options v1.GetOptio } // List takes label and field selectors, and returns the list of StatefulSets that match those selectors. -func (c *statefulSets) List(ctx context.Context, opts v1.ListOptions) (result *v1beta1.StatefulSetList, err error) { - defer func() { +func (c *statefulSets) List(ctx context.Context, opts v1.ListOptions) (*v1beta1.StatefulSetList, error) { + if watchListOptions, hasWatchListOptionsPrepared, watchListOptionsErr := watchlist.PrepareWatchListOptionsFromListOptions(opts); watchListOptionsErr != nil { + klog.Warningf("Failed preparing watchlist options for statefulsets, falling back to the standard LIST semantics, err = %v", watchListOptionsErr) + } else if hasWatchListOptionsPrepared { + result, err := c.watchList(ctx, watchListOptions) if err == nil { - consistencydetector.CheckListFromCacheDataConsistencyIfRequested(ctx, "list request for statefulsets", c.list, opts, result) + consistencydetector.CheckWatchListFromCacheDataConsistencyIfRequested(ctx, "watchlist request for statefulsets", c.list, opts, result) + return result, nil } - }() - return c.list(ctx, opts) + klog.Warningf("The watchlist request for statefulsets ended with an error, falling back to the standard LIST semantics, err = %v", err) + } + result, err := c.list(ctx, opts) + if err == nil { + consistencydetector.CheckListFromCacheDataConsistencyIfRequested(ctx, "list request for statefulsets", c.list, opts, result) + } + return result, err } // list takes label and field selectors, and returns the list of StatefulSets that match those selectors. @@ -110,6 +121,23 @@ func (c *statefulSets) list(ctx context.Context, opts v1.ListOptions) (result *v return } +// watchList establishes a watch stream with the server and returns the list of StatefulSets +func (c *statefulSets) watchList(ctx context.Context, opts v1.ListOptions) (result *v1beta1.StatefulSetList, err error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + result = &v1beta1.StatefulSetList{} + err = c.client.Get(). + Namespace(c.ns). + Resource("statefulsets"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + WatchList(ctx). + Into(result) + return +} + // Watch returns a watch.Interface that watches the requested statefulSets. func (c *statefulSets) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { var timeout time.Duration diff --git a/staging/src/k8s.io/client-go/kubernetes/typed/apps/v1beta2/controllerrevision.go b/staging/src/k8s.io/client-go/kubernetes/typed/apps/v1beta2/controllerrevision.go index 9a97558ea54..62c539efcd1 100644 --- a/staging/src/k8s.io/client-go/kubernetes/typed/apps/v1beta2/controllerrevision.go +++ b/staging/src/k8s.io/client-go/kubernetes/typed/apps/v1beta2/controllerrevision.go @@ -32,6 +32,8 @@ import ( scheme "k8s.io/client-go/kubernetes/scheme" rest "k8s.io/client-go/rest" consistencydetector "k8s.io/client-go/util/consistencydetector" + watchlist "k8s.io/client-go/util/watchlist" + "k8s.io/klog/v2" ) // ControllerRevisionsGetter has a method to return a ControllerRevisionInterface. @@ -82,13 +84,22 @@ func (c *controllerRevisions) Get(ctx context.Context, name string, options v1.G } // List takes label and field selectors, and returns the list of ControllerRevisions that match those selectors. -func (c *controllerRevisions) List(ctx context.Context, opts v1.ListOptions) (result *v1beta2.ControllerRevisionList, err error) { - defer func() { +func (c *controllerRevisions) List(ctx context.Context, opts v1.ListOptions) (*v1beta2.ControllerRevisionList, error) { + if watchListOptions, hasWatchListOptionsPrepared, watchListOptionsErr := watchlist.PrepareWatchListOptionsFromListOptions(opts); watchListOptionsErr != nil { + klog.Warningf("Failed preparing watchlist options for controllerrevisions, falling back to the standard LIST semantics, err = %v", watchListOptionsErr) + } else if hasWatchListOptionsPrepared { + result, err := c.watchList(ctx, watchListOptions) if err == nil { - consistencydetector.CheckListFromCacheDataConsistencyIfRequested(ctx, "list request for controllerrevisions", c.list, opts, result) + consistencydetector.CheckWatchListFromCacheDataConsistencyIfRequested(ctx, "watchlist request for controllerrevisions", c.list, opts, result) + return result, nil } - }() - return c.list(ctx, opts) + klog.Warningf("The watchlist request for controllerrevisions ended with an error, falling back to the standard LIST semantics, err = %v", err) + } + result, err := c.list(ctx, opts) + if err == nil { + consistencydetector.CheckListFromCacheDataConsistencyIfRequested(ctx, "list request for controllerrevisions", c.list, opts, result) + } + return result, err } // list takes label and field selectors, and returns the list of ControllerRevisions that match those selectors. @@ -108,6 +119,23 @@ func (c *controllerRevisions) list(ctx context.Context, opts v1.ListOptions) (re return } +// watchList establishes a watch stream with the server and returns the list of ControllerRevisions +func (c *controllerRevisions) watchList(ctx context.Context, opts v1.ListOptions) (result *v1beta2.ControllerRevisionList, err error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + result = &v1beta2.ControllerRevisionList{} + err = c.client.Get(). + Namespace(c.ns). + Resource("controllerrevisions"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + WatchList(ctx). + Into(result) + return +} + // Watch returns a watch.Interface that watches the requested controllerRevisions. func (c *controllerRevisions) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { var timeout time.Duration diff --git a/staging/src/k8s.io/client-go/kubernetes/typed/apps/v1beta2/daemonset.go b/staging/src/k8s.io/client-go/kubernetes/typed/apps/v1beta2/daemonset.go index 2411dda802d..e4006bc5138 100644 --- a/staging/src/k8s.io/client-go/kubernetes/typed/apps/v1beta2/daemonset.go +++ b/staging/src/k8s.io/client-go/kubernetes/typed/apps/v1beta2/daemonset.go @@ -32,6 +32,8 @@ import ( scheme "k8s.io/client-go/kubernetes/scheme" rest "k8s.io/client-go/rest" consistencydetector "k8s.io/client-go/util/consistencydetector" + watchlist "k8s.io/client-go/util/watchlist" + "k8s.io/klog/v2" ) // DaemonSetsGetter has a method to return a DaemonSetInterface. @@ -84,13 +86,22 @@ func (c *daemonSets) Get(ctx context.Context, name string, options v1.GetOptions } // List takes label and field selectors, and returns the list of DaemonSets that match those selectors. -func (c *daemonSets) List(ctx context.Context, opts v1.ListOptions) (result *v1beta2.DaemonSetList, err error) { - defer func() { +func (c *daemonSets) List(ctx context.Context, opts v1.ListOptions) (*v1beta2.DaemonSetList, error) { + if watchListOptions, hasWatchListOptionsPrepared, watchListOptionsErr := watchlist.PrepareWatchListOptionsFromListOptions(opts); watchListOptionsErr != nil { + klog.Warningf("Failed preparing watchlist options for daemonsets, falling back to the standard LIST semantics, err = %v", watchListOptionsErr) + } else if hasWatchListOptionsPrepared { + result, err := c.watchList(ctx, watchListOptions) if err == nil { - consistencydetector.CheckListFromCacheDataConsistencyIfRequested(ctx, "list request for daemonsets", c.list, opts, result) + consistencydetector.CheckWatchListFromCacheDataConsistencyIfRequested(ctx, "watchlist request for daemonsets", c.list, opts, result) + return result, nil } - }() - return c.list(ctx, opts) + klog.Warningf("The watchlist request for daemonsets ended with an error, falling back to the standard LIST semantics, err = %v", err) + } + result, err := c.list(ctx, opts) + if err == nil { + consistencydetector.CheckListFromCacheDataConsistencyIfRequested(ctx, "list request for daemonsets", c.list, opts, result) + } + return result, err } // list takes label and field selectors, and returns the list of DaemonSets that match those selectors. @@ -110,6 +121,23 @@ func (c *daemonSets) list(ctx context.Context, opts v1.ListOptions) (result *v1b return } +// watchList establishes a watch stream with the server and returns the list of DaemonSets +func (c *daemonSets) watchList(ctx context.Context, opts v1.ListOptions) (result *v1beta2.DaemonSetList, err error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + result = &v1beta2.DaemonSetList{} + err = c.client.Get(). + Namespace(c.ns). + Resource("daemonsets"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + WatchList(ctx). + Into(result) + return +} + // Watch returns a watch.Interface that watches the requested daemonSets. func (c *daemonSets) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { var timeout time.Duration diff --git a/staging/src/k8s.io/client-go/kubernetes/typed/apps/v1beta2/deployment.go b/staging/src/k8s.io/client-go/kubernetes/typed/apps/v1beta2/deployment.go index ced67eb0d82..43e48cdb2ec 100644 --- a/staging/src/k8s.io/client-go/kubernetes/typed/apps/v1beta2/deployment.go +++ b/staging/src/k8s.io/client-go/kubernetes/typed/apps/v1beta2/deployment.go @@ -32,6 +32,8 @@ import ( scheme "k8s.io/client-go/kubernetes/scheme" rest "k8s.io/client-go/rest" consistencydetector "k8s.io/client-go/util/consistencydetector" + watchlist "k8s.io/client-go/util/watchlist" + "k8s.io/klog/v2" ) // DeploymentsGetter has a method to return a DeploymentInterface. @@ -84,13 +86,22 @@ func (c *deployments) Get(ctx context.Context, name string, options v1.GetOption } // List takes label and field selectors, and returns the list of Deployments that match those selectors. -func (c *deployments) List(ctx context.Context, opts v1.ListOptions) (result *v1beta2.DeploymentList, err error) { - defer func() { +func (c *deployments) List(ctx context.Context, opts v1.ListOptions) (*v1beta2.DeploymentList, error) { + if watchListOptions, hasWatchListOptionsPrepared, watchListOptionsErr := watchlist.PrepareWatchListOptionsFromListOptions(opts); watchListOptionsErr != nil { + klog.Warningf("Failed preparing watchlist options for deployments, falling back to the standard LIST semantics, err = %v", watchListOptionsErr) + } else if hasWatchListOptionsPrepared { + result, err := c.watchList(ctx, watchListOptions) if err == nil { - consistencydetector.CheckListFromCacheDataConsistencyIfRequested(ctx, "list request for deployments", c.list, opts, result) + consistencydetector.CheckWatchListFromCacheDataConsistencyIfRequested(ctx, "watchlist request for deployments", c.list, opts, result) + return result, nil } - }() - return c.list(ctx, opts) + klog.Warningf("The watchlist request for deployments ended with an error, falling back to the standard LIST semantics, err = %v", err) + } + result, err := c.list(ctx, opts) + if err == nil { + consistencydetector.CheckListFromCacheDataConsistencyIfRequested(ctx, "list request for deployments", c.list, opts, result) + } + return result, err } // list takes label and field selectors, and returns the list of Deployments that match those selectors. @@ -110,6 +121,23 @@ func (c *deployments) list(ctx context.Context, opts v1.ListOptions) (result *v1 return } +// watchList establishes a watch stream with the server and returns the list of Deployments +func (c *deployments) watchList(ctx context.Context, opts v1.ListOptions) (result *v1beta2.DeploymentList, err error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + result = &v1beta2.DeploymentList{} + err = c.client.Get(). + Namespace(c.ns). + Resource("deployments"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + WatchList(ctx). + Into(result) + return +} + // Watch returns a watch.Interface that watches the requested deployments. func (c *deployments) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { var timeout time.Duration diff --git a/staging/src/k8s.io/client-go/kubernetes/typed/apps/v1beta2/replicaset.go b/staging/src/k8s.io/client-go/kubernetes/typed/apps/v1beta2/replicaset.go index 17f9a737d02..5d815771ce2 100644 --- a/staging/src/k8s.io/client-go/kubernetes/typed/apps/v1beta2/replicaset.go +++ b/staging/src/k8s.io/client-go/kubernetes/typed/apps/v1beta2/replicaset.go @@ -32,6 +32,8 @@ import ( scheme "k8s.io/client-go/kubernetes/scheme" rest "k8s.io/client-go/rest" consistencydetector "k8s.io/client-go/util/consistencydetector" + watchlist "k8s.io/client-go/util/watchlist" + "k8s.io/klog/v2" ) // ReplicaSetsGetter has a method to return a ReplicaSetInterface. @@ -84,13 +86,22 @@ func (c *replicaSets) Get(ctx context.Context, name string, options v1.GetOption } // List takes label and field selectors, and returns the list of ReplicaSets that match those selectors. -func (c *replicaSets) List(ctx context.Context, opts v1.ListOptions) (result *v1beta2.ReplicaSetList, err error) { - defer func() { +func (c *replicaSets) List(ctx context.Context, opts v1.ListOptions) (*v1beta2.ReplicaSetList, error) { + if watchListOptions, hasWatchListOptionsPrepared, watchListOptionsErr := watchlist.PrepareWatchListOptionsFromListOptions(opts); watchListOptionsErr != nil { + klog.Warningf("Failed preparing watchlist options for replicasets, falling back to the standard LIST semantics, err = %v", watchListOptionsErr) + } else if hasWatchListOptionsPrepared { + result, err := c.watchList(ctx, watchListOptions) if err == nil { - consistencydetector.CheckListFromCacheDataConsistencyIfRequested(ctx, "list request for replicasets", c.list, opts, result) + consistencydetector.CheckWatchListFromCacheDataConsistencyIfRequested(ctx, "watchlist request for replicasets", c.list, opts, result) + return result, nil } - }() - return c.list(ctx, opts) + klog.Warningf("The watchlist request for replicasets ended with an error, falling back to the standard LIST semantics, err = %v", err) + } + result, err := c.list(ctx, opts) + if err == nil { + consistencydetector.CheckListFromCacheDataConsistencyIfRequested(ctx, "list request for replicasets", c.list, opts, result) + } + return result, err } // list takes label and field selectors, and returns the list of ReplicaSets that match those selectors. @@ -110,6 +121,23 @@ func (c *replicaSets) list(ctx context.Context, opts v1.ListOptions) (result *v1 return } +// watchList establishes a watch stream with the server and returns the list of ReplicaSets +func (c *replicaSets) watchList(ctx context.Context, opts v1.ListOptions) (result *v1beta2.ReplicaSetList, err error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + result = &v1beta2.ReplicaSetList{} + err = c.client.Get(). + Namespace(c.ns). + Resource("replicasets"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + WatchList(ctx). + Into(result) + return +} + // Watch returns a watch.Interface that watches the requested replicaSets. func (c *replicaSets) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { var timeout time.Duration diff --git a/staging/src/k8s.io/client-go/kubernetes/typed/apps/v1beta2/statefulset.go b/staging/src/k8s.io/client-go/kubernetes/typed/apps/v1beta2/statefulset.go index 0ddb1095f97..923a10cb353 100644 --- a/staging/src/k8s.io/client-go/kubernetes/typed/apps/v1beta2/statefulset.go +++ b/staging/src/k8s.io/client-go/kubernetes/typed/apps/v1beta2/statefulset.go @@ -32,6 +32,8 @@ import ( scheme "k8s.io/client-go/kubernetes/scheme" rest "k8s.io/client-go/rest" consistencydetector "k8s.io/client-go/util/consistencydetector" + watchlist "k8s.io/client-go/util/watchlist" + "k8s.io/klog/v2" ) // StatefulSetsGetter has a method to return a StatefulSetInterface. @@ -88,13 +90,22 @@ func (c *statefulSets) Get(ctx context.Context, name string, options v1.GetOptio } // List takes label and field selectors, and returns the list of StatefulSets that match those selectors. -func (c *statefulSets) List(ctx context.Context, opts v1.ListOptions) (result *v1beta2.StatefulSetList, err error) { - defer func() { +func (c *statefulSets) List(ctx context.Context, opts v1.ListOptions) (*v1beta2.StatefulSetList, error) { + if watchListOptions, hasWatchListOptionsPrepared, watchListOptionsErr := watchlist.PrepareWatchListOptionsFromListOptions(opts); watchListOptionsErr != nil { + klog.Warningf("Failed preparing watchlist options for statefulsets, falling back to the standard LIST semantics, err = %v", watchListOptionsErr) + } else if hasWatchListOptionsPrepared { + result, err := c.watchList(ctx, watchListOptions) if err == nil { - consistencydetector.CheckListFromCacheDataConsistencyIfRequested(ctx, "list request for statefulsets", c.list, opts, result) + consistencydetector.CheckWatchListFromCacheDataConsistencyIfRequested(ctx, "watchlist request for statefulsets", c.list, opts, result) + return result, nil } - }() - return c.list(ctx, opts) + klog.Warningf("The watchlist request for statefulsets ended with an error, falling back to the standard LIST semantics, err = %v", err) + } + result, err := c.list(ctx, opts) + if err == nil { + consistencydetector.CheckListFromCacheDataConsistencyIfRequested(ctx, "list request for statefulsets", c.list, opts, result) + } + return result, err } // list takes label and field selectors, and returns the list of StatefulSets that match those selectors. @@ -114,6 +125,23 @@ func (c *statefulSets) list(ctx context.Context, opts v1.ListOptions) (result *v return } +// watchList establishes a watch stream with the server and returns the list of StatefulSets +func (c *statefulSets) watchList(ctx context.Context, opts v1.ListOptions) (result *v1beta2.StatefulSetList, err error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + result = &v1beta2.StatefulSetList{} + err = c.client.Get(). + Namespace(c.ns). + Resource("statefulsets"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + WatchList(ctx). + Into(result) + return +} + // Watch returns a watch.Interface that watches the requested statefulSets. func (c *statefulSets) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { var timeout time.Duration diff --git a/staging/src/k8s.io/client-go/kubernetes/typed/autoscaling/v1/horizontalpodautoscaler.go b/staging/src/k8s.io/client-go/kubernetes/typed/autoscaling/v1/horizontalpodautoscaler.go index bba45318318..66a3d792453 100644 --- a/staging/src/k8s.io/client-go/kubernetes/typed/autoscaling/v1/horizontalpodautoscaler.go +++ b/staging/src/k8s.io/client-go/kubernetes/typed/autoscaling/v1/horizontalpodautoscaler.go @@ -32,6 +32,8 @@ import ( scheme "k8s.io/client-go/kubernetes/scheme" rest "k8s.io/client-go/rest" consistencydetector "k8s.io/client-go/util/consistencydetector" + watchlist "k8s.io/client-go/util/watchlist" + "k8s.io/klog/v2" ) // HorizontalPodAutoscalersGetter has a method to return a HorizontalPodAutoscalerInterface. @@ -84,13 +86,22 @@ func (c *horizontalPodAutoscalers) Get(ctx context.Context, name string, options } // List takes label and field selectors, and returns the list of HorizontalPodAutoscalers that match those selectors. -func (c *horizontalPodAutoscalers) List(ctx context.Context, opts metav1.ListOptions) (result *v1.HorizontalPodAutoscalerList, err error) { - defer func() { +func (c *horizontalPodAutoscalers) List(ctx context.Context, opts metav1.ListOptions) (*v1.HorizontalPodAutoscalerList, error) { + if watchListOptions, hasWatchListOptionsPrepared, watchListOptionsErr := watchlist.PrepareWatchListOptionsFromListOptions(opts); watchListOptionsErr != nil { + klog.Warningf("Failed preparing watchlist options for horizontalpodautoscalers, falling back to the standard LIST semantics, err = %v", watchListOptionsErr) + } else if hasWatchListOptionsPrepared { + result, err := c.watchList(ctx, watchListOptions) if err == nil { - consistencydetector.CheckListFromCacheDataConsistencyIfRequested(ctx, "list request for horizontalpodautoscalers", c.list, opts, result) + consistencydetector.CheckWatchListFromCacheDataConsistencyIfRequested(ctx, "watchlist request for horizontalpodautoscalers", c.list, opts, result) + return result, nil } - }() - return c.list(ctx, opts) + klog.Warningf("The watchlist request for horizontalpodautoscalers ended with an error, falling back to the standard LIST semantics, err = %v", err) + } + result, err := c.list(ctx, opts) + if err == nil { + consistencydetector.CheckListFromCacheDataConsistencyIfRequested(ctx, "list request for horizontalpodautoscalers", c.list, opts, result) + } + return result, err } // list takes label and field selectors, and returns the list of HorizontalPodAutoscalers that match those selectors. @@ -110,6 +121,23 @@ func (c *horizontalPodAutoscalers) list(ctx context.Context, opts metav1.ListOpt return } +// watchList establishes a watch stream with the server and returns the list of HorizontalPodAutoscalers +func (c *horizontalPodAutoscalers) watchList(ctx context.Context, opts metav1.ListOptions) (result *v1.HorizontalPodAutoscalerList, err error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + result = &v1.HorizontalPodAutoscalerList{} + err = c.client.Get(). + Namespace(c.ns). + Resource("horizontalpodautoscalers"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + WatchList(ctx). + Into(result) + return +} + // Watch returns a watch.Interface that watches the requested horizontalPodAutoscalers. func (c *horizontalPodAutoscalers) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { var timeout time.Duration diff --git a/staging/src/k8s.io/client-go/kubernetes/typed/autoscaling/v2/horizontalpodautoscaler.go b/staging/src/k8s.io/client-go/kubernetes/typed/autoscaling/v2/horizontalpodautoscaler.go index 2eb1165e63e..278614af8e0 100644 --- a/staging/src/k8s.io/client-go/kubernetes/typed/autoscaling/v2/horizontalpodautoscaler.go +++ b/staging/src/k8s.io/client-go/kubernetes/typed/autoscaling/v2/horizontalpodautoscaler.go @@ -32,6 +32,8 @@ import ( scheme "k8s.io/client-go/kubernetes/scheme" rest "k8s.io/client-go/rest" consistencydetector "k8s.io/client-go/util/consistencydetector" + watchlist "k8s.io/client-go/util/watchlist" + "k8s.io/klog/v2" ) // HorizontalPodAutoscalersGetter has a method to return a HorizontalPodAutoscalerInterface. @@ -84,13 +86,22 @@ func (c *horizontalPodAutoscalers) Get(ctx context.Context, name string, options } // List takes label and field selectors, and returns the list of HorizontalPodAutoscalers that match those selectors. -func (c *horizontalPodAutoscalers) List(ctx context.Context, opts v1.ListOptions) (result *v2.HorizontalPodAutoscalerList, err error) { - defer func() { +func (c *horizontalPodAutoscalers) List(ctx context.Context, opts v1.ListOptions) (*v2.HorizontalPodAutoscalerList, error) { + if watchListOptions, hasWatchListOptionsPrepared, watchListOptionsErr := watchlist.PrepareWatchListOptionsFromListOptions(opts); watchListOptionsErr != nil { + klog.Warningf("Failed preparing watchlist options for horizontalpodautoscalers, falling back to the standard LIST semantics, err = %v", watchListOptionsErr) + } else if hasWatchListOptionsPrepared { + result, err := c.watchList(ctx, watchListOptions) if err == nil { - consistencydetector.CheckListFromCacheDataConsistencyIfRequested(ctx, "list request for horizontalpodautoscalers", c.list, opts, result) + consistencydetector.CheckWatchListFromCacheDataConsistencyIfRequested(ctx, "watchlist request for horizontalpodautoscalers", c.list, opts, result) + return result, nil } - }() - return c.list(ctx, opts) + klog.Warningf("The watchlist request for horizontalpodautoscalers ended with an error, falling back to the standard LIST semantics, err = %v", err) + } + result, err := c.list(ctx, opts) + if err == nil { + consistencydetector.CheckListFromCacheDataConsistencyIfRequested(ctx, "list request for horizontalpodautoscalers", c.list, opts, result) + } + return result, err } // list takes label and field selectors, and returns the list of HorizontalPodAutoscalers that match those selectors. @@ -110,6 +121,23 @@ func (c *horizontalPodAutoscalers) list(ctx context.Context, opts v1.ListOptions return } +// watchList establishes a watch stream with the server and returns the list of HorizontalPodAutoscalers +func (c *horizontalPodAutoscalers) watchList(ctx context.Context, opts v1.ListOptions) (result *v2.HorizontalPodAutoscalerList, err error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + result = &v2.HorizontalPodAutoscalerList{} + err = c.client.Get(). + Namespace(c.ns). + Resource("horizontalpodautoscalers"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + WatchList(ctx). + Into(result) + return +} + // Watch returns a watch.Interface that watches the requested horizontalPodAutoscalers. func (c *horizontalPodAutoscalers) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { var timeout time.Duration diff --git a/staging/src/k8s.io/client-go/kubernetes/typed/autoscaling/v2beta1/horizontalpodautoscaler.go b/staging/src/k8s.io/client-go/kubernetes/typed/autoscaling/v2beta1/horizontalpodautoscaler.go index 5912300c213..76c9ce3f5c9 100644 --- a/staging/src/k8s.io/client-go/kubernetes/typed/autoscaling/v2beta1/horizontalpodautoscaler.go +++ b/staging/src/k8s.io/client-go/kubernetes/typed/autoscaling/v2beta1/horizontalpodautoscaler.go @@ -32,6 +32,8 @@ import ( scheme "k8s.io/client-go/kubernetes/scheme" rest "k8s.io/client-go/rest" consistencydetector "k8s.io/client-go/util/consistencydetector" + watchlist "k8s.io/client-go/util/watchlist" + "k8s.io/klog/v2" ) // HorizontalPodAutoscalersGetter has a method to return a HorizontalPodAutoscalerInterface. @@ -84,13 +86,22 @@ func (c *horizontalPodAutoscalers) Get(ctx context.Context, name string, options } // List takes label and field selectors, and returns the list of HorizontalPodAutoscalers that match those selectors. -func (c *horizontalPodAutoscalers) List(ctx context.Context, opts v1.ListOptions) (result *v2beta1.HorizontalPodAutoscalerList, err error) { - defer func() { +func (c *horizontalPodAutoscalers) List(ctx context.Context, opts v1.ListOptions) (*v2beta1.HorizontalPodAutoscalerList, error) { + if watchListOptions, hasWatchListOptionsPrepared, watchListOptionsErr := watchlist.PrepareWatchListOptionsFromListOptions(opts); watchListOptionsErr != nil { + klog.Warningf("Failed preparing watchlist options for horizontalpodautoscalers, falling back to the standard LIST semantics, err = %v", watchListOptionsErr) + } else if hasWatchListOptionsPrepared { + result, err := c.watchList(ctx, watchListOptions) if err == nil { - consistencydetector.CheckListFromCacheDataConsistencyIfRequested(ctx, "list request for horizontalpodautoscalers", c.list, opts, result) + consistencydetector.CheckWatchListFromCacheDataConsistencyIfRequested(ctx, "watchlist request for horizontalpodautoscalers", c.list, opts, result) + return result, nil } - }() - return c.list(ctx, opts) + klog.Warningf("The watchlist request for horizontalpodautoscalers ended with an error, falling back to the standard LIST semantics, err = %v", err) + } + result, err := c.list(ctx, opts) + if err == nil { + consistencydetector.CheckListFromCacheDataConsistencyIfRequested(ctx, "list request for horizontalpodautoscalers", c.list, opts, result) + } + return result, err } // list takes label and field selectors, and returns the list of HorizontalPodAutoscalers that match those selectors. @@ -110,6 +121,23 @@ func (c *horizontalPodAutoscalers) list(ctx context.Context, opts v1.ListOptions return } +// watchList establishes a watch stream with the server and returns the list of HorizontalPodAutoscalers +func (c *horizontalPodAutoscalers) watchList(ctx context.Context, opts v1.ListOptions) (result *v2beta1.HorizontalPodAutoscalerList, err error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + result = &v2beta1.HorizontalPodAutoscalerList{} + err = c.client.Get(). + Namespace(c.ns). + Resource("horizontalpodautoscalers"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + WatchList(ctx). + Into(result) + return +} + // Watch returns a watch.Interface that watches the requested horizontalPodAutoscalers. func (c *horizontalPodAutoscalers) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { var timeout time.Duration diff --git a/staging/src/k8s.io/client-go/kubernetes/typed/autoscaling/v2beta2/horizontalpodautoscaler.go b/staging/src/k8s.io/client-go/kubernetes/typed/autoscaling/v2beta2/horizontalpodautoscaler.go index 518e0c26a0f..3da8fa9280a 100644 --- a/staging/src/k8s.io/client-go/kubernetes/typed/autoscaling/v2beta2/horizontalpodautoscaler.go +++ b/staging/src/k8s.io/client-go/kubernetes/typed/autoscaling/v2beta2/horizontalpodautoscaler.go @@ -32,6 +32,8 @@ import ( scheme "k8s.io/client-go/kubernetes/scheme" rest "k8s.io/client-go/rest" consistencydetector "k8s.io/client-go/util/consistencydetector" + watchlist "k8s.io/client-go/util/watchlist" + "k8s.io/klog/v2" ) // HorizontalPodAutoscalersGetter has a method to return a HorizontalPodAutoscalerInterface. @@ -84,13 +86,22 @@ func (c *horizontalPodAutoscalers) Get(ctx context.Context, name string, options } // List takes label and field selectors, and returns the list of HorizontalPodAutoscalers that match those selectors. -func (c *horizontalPodAutoscalers) List(ctx context.Context, opts v1.ListOptions) (result *v2beta2.HorizontalPodAutoscalerList, err error) { - defer func() { +func (c *horizontalPodAutoscalers) List(ctx context.Context, opts v1.ListOptions) (*v2beta2.HorizontalPodAutoscalerList, error) { + if watchListOptions, hasWatchListOptionsPrepared, watchListOptionsErr := watchlist.PrepareWatchListOptionsFromListOptions(opts); watchListOptionsErr != nil { + klog.Warningf("Failed preparing watchlist options for horizontalpodautoscalers, falling back to the standard LIST semantics, err = %v", watchListOptionsErr) + } else if hasWatchListOptionsPrepared { + result, err := c.watchList(ctx, watchListOptions) if err == nil { - consistencydetector.CheckListFromCacheDataConsistencyIfRequested(ctx, "list request for horizontalpodautoscalers", c.list, opts, result) + consistencydetector.CheckWatchListFromCacheDataConsistencyIfRequested(ctx, "watchlist request for horizontalpodautoscalers", c.list, opts, result) + return result, nil } - }() - return c.list(ctx, opts) + klog.Warningf("The watchlist request for horizontalpodautoscalers ended with an error, falling back to the standard LIST semantics, err = %v", err) + } + result, err := c.list(ctx, opts) + if err == nil { + consistencydetector.CheckListFromCacheDataConsistencyIfRequested(ctx, "list request for horizontalpodautoscalers", c.list, opts, result) + } + return result, err } // list takes label and field selectors, and returns the list of HorizontalPodAutoscalers that match those selectors. @@ -110,6 +121,23 @@ func (c *horizontalPodAutoscalers) list(ctx context.Context, opts v1.ListOptions return } +// watchList establishes a watch stream with the server and returns the list of HorizontalPodAutoscalers +func (c *horizontalPodAutoscalers) watchList(ctx context.Context, opts v1.ListOptions) (result *v2beta2.HorizontalPodAutoscalerList, err error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + result = &v2beta2.HorizontalPodAutoscalerList{} + err = c.client.Get(). + Namespace(c.ns). + Resource("horizontalpodautoscalers"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + WatchList(ctx). + Into(result) + return +} + // Watch returns a watch.Interface that watches the requested horizontalPodAutoscalers. func (c *horizontalPodAutoscalers) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { var timeout time.Duration diff --git a/staging/src/k8s.io/client-go/kubernetes/typed/batch/v1/cronjob.go b/staging/src/k8s.io/client-go/kubernetes/typed/batch/v1/cronjob.go index a16ec5ba51d..763176c4c4c 100644 --- a/staging/src/k8s.io/client-go/kubernetes/typed/batch/v1/cronjob.go +++ b/staging/src/k8s.io/client-go/kubernetes/typed/batch/v1/cronjob.go @@ -32,6 +32,8 @@ import ( scheme "k8s.io/client-go/kubernetes/scheme" rest "k8s.io/client-go/rest" consistencydetector "k8s.io/client-go/util/consistencydetector" + watchlist "k8s.io/client-go/util/watchlist" + "k8s.io/klog/v2" ) // CronJobsGetter has a method to return a CronJobInterface. @@ -84,13 +86,22 @@ func (c *cronJobs) Get(ctx context.Context, name string, options metav1.GetOptio } // List takes label and field selectors, and returns the list of CronJobs that match those selectors. -func (c *cronJobs) List(ctx context.Context, opts metav1.ListOptions) (result *v1.CronJobList, err error) { - defer func() { +func (c *cronJobs) List(ctx context.Context, opts metav1.ListOptions) (*v1.CronJobList, error) { + if watchListOptions, hasWatchListOptionsPrepared, watchListOptionsErr := watchlist.PrepareWatchListOptionsFromListOptions(opts); watchListOptionsErr != nil { + klog.Warningf("Failed preparing watchlist options for cronjobs, falling back to the standard LIST semantics, err = %v", watchListOptionsErr) + } else if hasWatchListOptionsPrepared { + result, err := c.watchList(ctx, watchListOptions) if err == nil { - consistencydetector.CheckListFromCacheDataConsistencyIfRequested(ctx, "list request for cronjobs", c.list, opts, result) + consistencydetector.CheckWatchListFromCacheDataConsistencyIfRequested(ctx, "watchlist request for cronjobs", c.list, opts, result) + return result, nil } - }() - return c.list(ctx, opts) + klog.Warningf("The watchlist request for cronjobs ended with an error, falling back to the standard LIST semantics, err = %v", err) + } + result, err := c.list(ctx, opts) + if err == nil { + consistencydetector.CheckListFromCacheDataConsistencyIfRequested(ctx, "list request for cronjobs", c.list, opts, result) + } + return result, err } // list takes label and field selectors, and returns the list of CronJobs that match those selectors. @@ -110,6 +121,23 @@ func (c *cronJobs) list(ctx context.Context, opts metav1.ListOptions) (result *v return } +// watchList establishes a watch stream with the server and returns the list of CronJobs +func (c *cronJobs) watchList(ctx context.Context, opts metav1.ListOptions) (result *v1.CronJobList, err error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + result = &v1.CronJobList{} + err = c.client.Get(). + Namespace(c.ns). + Resource("cronjobs"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + WatchList(ctx). + Into(result) + return +} + // Watch returns a watch.Interface that watches the requested cronJobs. func (c *cronJobs) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { var timeout time.Duration diff --git a/staging/src/k8s.io/client-go/kubernetes/typed/batch/v1/job.go b/staging/src/k8s.io/client-go/kubernetes/typed/batch/v1/job.go index 6663bceb277..148b68aed0f 100644 --- a/staging/src/k8s.io/client-go/kubernetes/typed/batch/v1/job.go +++ b/staging/src/k8s.io/client-go/kubernetes/typed/batch/v1/job.go @@ -32,6 +32,8 @@ import ( scheme "k8s.io/client-go/kubernetes/scheme" rest "k8s.io/client-go/rest" consistencydetector "k8s.io/client-go/util/consistencydetector" + watchlist "k8s.io/client-go/util/watchlist" + "k8s.io/klog/v2" ) // JobsGetter has a method to return a JobInterface. @@ -84,13 +86,22 @@ func (c *jobs) Get(ctx context.Context, name string, options metav1.GetOptions) } // List takes label and field selectors, and returns the list of Jobs that match those selectors. -func (c *jobs) List(ctx context.Context, opts metav1.ListOptions) (result *v1.JobList, err error) { - defer func() { +func (c *jobs) List(ctx context.Context, opts metav1.ListOptions) (*v1.JobList, error) { + if watchListOptions, hasWatchListOptionsPrepared, watchListOptionsErr := watchlist.PrepareWatchListOptionsFromListOptions(opts); watchListOptionsErr != nil { + klog.Warningf("Failed preparing watchlist options for jobs, falling back to the standard LIST semantics, err = %v", watchListOptionsErr) + } else if hasWatchListOptionsPrepared { + result, err := c.watchList(ctx, watchListOptions) if err == nil { - consistencydetector.CheckListFromCacheDataConsistencyIfRequested(ctx, "list request for jobs", c.list, opts, result) + consistencydetector.CheckWatchListFromCacheDataConsistencyIfRequested(ctx, "watchlist request for jobs", c.list, opts, result) + return result, nil } - }() - return c.list(ctx, opts) + klog.Warningf("The watchlist request for jobs ended with an error, falling back to the standard LIST semantics, err = %v", err) + } + result, err := c.list(ctx, opts) + if err == nil { + consistencydetector.CheckListFromCacheDataConsistencyIfRequested(ctx, "list request for jobs", c.list, opts, result) + } + return result, err } // list takes label and field selectors, and returns the list of Jobs that match those selectors. @@ -110,6 +121,23 @@ func (c *jobs) list(ctx context.Context, opts metav1.ListOptions) (result *v1.Jo return } +// watchList establishes a watch stream with the server and returns the list of Jobs +func (c *jobs) watchList(ctx context.Context, opts metav1.ListOptions) (result *v1.JobList, err error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + result = &v1.JobList{} + err = c.client.Get(). + Namespace(c.ns). + Resource("jobs"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + WatchList(ctx). + Into(result) + return +} + // Watch returns a watch.Interface that watches the requested jobs. func (c *jobs) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { var timeout time.Duration diff --git a/staging/src/k8s.io/client-go/kubernetes/typed/batch/v1beta1/cronjob.go b/staging/src/k8s.io/client-go/kubernetes/typed/batch/v1beta1/cronjob.go index 0401f2249ad..e6ee1fc143b 100644 --- a/staging/src/k8s.io/client-go/kubernetes/typed/batch/v1beta1/cronjob.go +++ b/staging/src/k8s.io/client-go/kubernetes/typed/batch/v1beta1/cronjob.go @@ -32,6 +32,8 @@ import ( scheme "k8s.io/client-go/kubernetes/scheme" rest "k8s.io/client-go/rest" consistencydetector "k8s.io/client-go/util/consistencydetector" + watchlist "k8s.io/client-go/util/watchlist" + "k8s.io/klog/v2" ) // CronJobsGetter has a method to return a CronJobInterface. @@ -84,13 +86,22 @@ func (c *cronJobs) Get(ctx context.Context, name string, options v1.GetOptions) } // List takes label and field selectors, and returns the list of CronJobs that match those selectors. -func (c *cronJobs) List(ctx context.Context, opts v1.ListOptions) (result *v1beta1.CronJobList, err error) { - defer func() { +func (c *cronJobs) List(ctx context.Context, opts v1.ListOptions) (*v1beta1.CronJobList, error) { + if watchListOptions, hasWatchListOptionsPrepared, watchListOptionsErr := watchlist.PrepareWatchListOptionsFromListOptions(opts); watchListOptionsErr != nil { + klog.Warningf("Failed preparing watchlist options for cronjobs, falling back to the standard LIST semantics, err = %v", watchListOptionsErr) + } else if hasWatchListOptionsPrepared { + result, err := c.watchList(ctx, watchListOptions) if err == nil { - consistencydetector.CheckListFromCacheDataConsistencyIfRequested(ctx, "list request for cronjobs", c.list, opts, result) + consistencydetector.CheckWatchListFromCacheDataConsistencyIfRequested(ctx, "watchlist request for cronjobs", c.list, opts, result) + return result, nil } - }() - return c.list(ctx, opts) + klog.Warningf("The watchlist request for cronjobs ended with an error, falling back to the standard LIST semantics, err = %v", err) + } + result, err := c.list(ctx, opts) + if err == nil { + consistencydetector.CheckListFromCacheDataConsistencyIfRequested(ctx, "list request for cronjobs", c.list, opts, result) + } + return result, err } // list takes label and field selectors, and returns the list of CronJobs that match those selectors. @@ -110,6 +121,23 @@ func (c *cronJobs) list(ctx context.Context, opts v1.ListOptions) (result *v1bet return } +// watchList establishes a watch stream with the server and returns the list of CronJobs +func (c *cronJobs) watchList(ctx context.Context, opts v1.ListOptions) (result *v1beta1.CronJobList, err error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + result = &v1beta1.CronJobList{} + err = c.client.Get(). + Namespace(c.ns). + Resource("cronjobs"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + WatchList(ctx). + Into(result) + return +} + // Watch returns a watch.Interface that watches the requested cronJobs. func (c *cronJobs) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { var timeout time.Duration diff --git a/staging/src/k8s.io/client-go/kubernetes/typed/certificates/v1/certificatesigningrequest.go b/staging/src/k8s.io/client-go/kubernetes/typed/certificates/v1/certificatesigningrequest.go index 79c9daf3e50..bcc6841a1d4 100644 --- a/staging/src/k8s.io/client-go/kubernetes/typed/certificates/v1/certificatesigningrequest.go +++ b/staging/src/k8s.io/client-go/kubernetes/typed/certificates/v1/certificatesigningrequest.go @@ -32,6 +32,8 @@ import ( scheme "k8s.io/client-go/kubernetes/scheme" rest "k8s.io/client-go/rest" consistencydetector "k8s.io/client-go/util/consistencydetector" + watchlist "k8s.io/client-go/util/watchlist" + "k8s.io/klog/v2" ) // CertificateSigningRequestsGetter has a method to return a CertificateSigningRequestInterface. @@ -83,13 +85,22 @@ func (c *certificateSigningRequests) Get(ctx context.Context, name string, optio } // List takes label and field selectors, and returns the list of CertificateSigningRequests that match those selectors. -func (c *certificateSigningRequests) List(ctx context.Context, opts metav1.ListOptions) (result *v1.CertificateSigningRequestList, err error) { - defer func() { +func (c *certificateSigningRequests) List(ctx context.Context, opts metav1.ListOptions) (*v1.CertificateSigningRequestList, error) { + if watchListOptions, hasWatchListOptionsPrepared, watchListOptionsErr := watchlist.PrepareWatchListOptionsFromListOptions(opts); watchListOptionsErr != nil { + klog.Warningf("Failed preparing watchlist options for certificatesigningrequests, falling back to the standard LIST semantics, err = %v", watchListOptionsErr) + } else if hasWatchListOptionsPrepared { + result, err := c.watchList(ctx, watchListOptions) if err == nil { - consistencydetector.CheckListFromCacheDataConsistencyIfRequested(ctx, "list request for certificatesigningrequests", c.list, opts, result) + consistencydetector.CheckWatchListFromCacheDataConsistencyIfRequested(ctx, "watchlist request for certificatesigningrequests", c.list, opts, result) + return result, nil } - }() - return c.list(ctx, opts) + klog.Warningf("The watchlist request for certificatesigningrequests ended with an error, falling back to the standard LIST semantics, err = %v", err) + } + result, err := c.list(ctx, opts) + if err == nil { + consistencydetector.CheckListFromCacheDataConsistencyIfRequested(ctx, "list request for certificatesigningrequests", c.list, opts, result) + } + return result, err } // list takes label and field selectors, and returns the list of CertificateSigningRequests that match those selectors. @@ -108,6 +119,22 @@ func (c *certificateSigningRequests) list(ctx context.Context, opts metav1.ListO return } +// watchList establishes a watch stream with the server and returns the list of CertificateSigningRequests +func (c *certificateSigningRequests) watchList(ctx context.Context, opts metav1.ListOptions) (result *v1.CertificateSigningRequestList, err error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + result = &v1.CertificateSigningRequestList{} + err = c.client.Get(). + Resource("certificatesigningrequests"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + WatchList(ctx). + Into(result) + return +} + // Watch returns a watch.Interface that watches the requested certificateSigningRequests. func (c *certificateSigningRequests) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { var timeout time.Duration diff --git a/staging/src/k8s.io/client-go/kubernetes/typed/certificates/v1alpha1/clustertrustbundle.go b/staging/src/k8s.io/client-go/kubernetes/typed/certificates/v1alpha1/clustertrustbundle.go index c4e0ca65a0f..bfb1659b276 100644 --- a/staging/src/k8s.io/client-go/kubernetes/typed/certificates/v1alpha1/clustertrustbundle.go +++ b/staging/src/k8s.io/client-go/kubernetes/typed/certificates/v1alpha1/clustertrustbundle.go @@ -32,6 +32,8 @@ import ( scheme "k8s.io/client-go/kubernetes/scheme" rest "k8s.io/client-go/rest" consistencydetector "k8s.io/client-go/util/consistencydetector" + watchlist "k8s.io/client-go/util/watchlist" + "k8s.io/klog/v2" ) // ClusterTrustBundlesGetter has a method to return a ClusterTrustBundleInterface. @@ -79,13 +81,22 @@ func (c *clusterTrustBundles) Get(ctx context.Context, name string, options v1.G } // List takes label and field selectors, and returns the list of ClusterTrustBundles that match those selectors. -func (c *clusterTrustBundles) List(ctx context.Context, opts v1.ListOptions) (result *v1alpha1.ClusterTrustBundleList, err error) { - defer func() { +func (c *clusterTrustBundles) List(ctx context.Context, opts v1.ListOptions) (*v1alpha1.ClusterTrustBundleList, error) { + if watchListOptions, hasWatchListOptionsPrepared, watchListOptionsErr := watchlist.PrepareWatchListOptionsFromListOptions(opts); watchListOptionsErr != nil { + klog.Warningf("Failed preparing watchlist options for clustertrustbundles, falling back to the standard LIST semantics, err = %v", watchListOptionsErr) + } else if hasWatchListOptionsPrepared { + result, err := c.watchList(ctx, watchListOptions) if err == nil { - consistencydetector.CheckListFromCacheDataConsistencyIfRequested(ctx, "list request for clustertrustbundles", c.list, opts, result) + consistencydetector.CheckWatchListFromCacheDataConsistencyIfRequested(ctx, "watchlist request for clustertrustbundles", c.list, opts, result) + return result, nil } - }() - return c.list(ctx, opts) + klog.Warningf("The watchlist request for clustertrustbundles ended with an error, falling back to the standard LIST semantics, err = %v", err) + } + result, err := c.list(ctx, opts) + if err == nil { + consistencydetector.CheckListFromCacheDataConsistencyIfRequested(ctx, "list request for clustertrustbundles", c.list, opts, result) + } + return result, err } // list takes label and field selectors, and returns the list of ClusterTrustBundles that match those selectors. @@ -104,6 +115,22 @@ func (c *clusterTrustBundles) list(ctx context.Context, opts v1.ListOptions) (re return } +// watchList establishes a watch stream with the server and returns the list of ClusterTrustBundles +func (c *clusterTrustBundles) watchList(ctx context.Context, opts v1.ListOptions) (result *v1alpha1.ClusterTrustBundleList, err error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + result = &v1alpha1.ClusterTrustBundleList{} + err = c.client.Get(). + Resource("clustertrustbundles"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + WatchList(ctx). + Into(result) + return +} + // Watch returns a watch.Interface that watches the requested clusterTrustBundles. func (c *clusterTrustBundles) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { var timeout time.Duration diff --git a/staging/src/k8s.io/client-go/kubernetes/typed/certificates/v1beta1/certificatesigningrequest.go b/staging/src/k8s.io/client-go/kubernetes/typed/certificates/v1beta1/certificatesigningrequest.go index d88d4020c29..3abb541f508 100644 --- a/staging/src/k8s.io/client-go/kubernetes/typed/certificates/v1beta1/certificatesigningrequest.go +++ b/staging/src/k8s.io/client-go/kubernetes/typed/certificates/v1beta1/certificatesigningrequest.go @@ -32,6 +32,8 @@ import ( scheme "k8s.io/client-go/kubernetes/scheme" rest "k8s.io/client-go/rest" consistencydetector "k8s.io/client-go/util/consistencydetector" + watchlist "k8s.io/client-go/util/watchlist" + "k8s.io/klog/v2" ) // CertificateSigningRequestsGetter has a method to return a CertificateSigningRequestInterface. @@ -81,13 +83,22 @@ func (c *certificateSigningRequests) Get(ctx context.Context, name string, optio } // List takes label and field selectors, and returns the list of CertificateSigningRequests that match those selectors. -func (c *certificateSigningRequests) List(ctx context.Context, opts v1.ListOptions) (result *v1beta1.CertificateSigningRequestList, err error) { - defer func() { +func (c *certificateSigningRequests) List(ctx context.Context, opts v1.ListOptions) (*v1beta1.CertificateSigningRequestList, error) { + if watchListOptions, hasWatchListOptionsPrepared, watchListOptionsErr := watchlist.PrepareWatchListOptionsFromListOptions(opts); watchListOptionsErr != nil { + klog.Warningf("Failed preparing watchlist options for certificatesigningrequests, falling back to the standard LIST semantics, err = %v", watchListOptionsErr) + } else if hasWatchListOptionsPrepared { + result, err := c.watchList(ctx, watchListOptions) if err == nil { - consistencydetector.CheckListFromCacheDataConsistencyIfRequested(ctx, "list request for certificatesigningrequests", c.list, opts, result) + consistencydetector.CheckWatchListFromCacheDataConsistencyIfRequested(ctx, "watchlist request for certificatesigningrequests", c.list, opts, result) + return result, nil } - }() - return c.list(ctx, opts) + klog.Warningf("The watchlist request for certificatesigningrequests ended with an error, falling back to the standard LIST semantics, err = %v", err) + } + result, err := c.list(ctx, opts) + if err == nil { + consistencydetector.CheckListFromCacheDataConsistencyIfRequested(ctx, "list request for certificatesigningrequests", c.list, opts, result) + } + return result, err } // list takes label and field selectors, and returns the list of CertificateSigningRequests that match those selectors. @@ -106,6 +117,22 @@ func (c *certificateSigningRequests) list(ctx context.Context, opts v1.ListOptio return } +// watchList establishes a watch stream with the server and returns the list of CertificateSigningRequests +func (c *certificateSigningRequests) watchList(ctx context.Context, opts v1.ListOptions) (result *v1beta1.CertificateSigningRequestList, err error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + result = &v1beta1.CertificateSigningRequestList{} + err = c.client.Get(). + Resource("certificatesigningrequests"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + WatchList(ctx). + Into(result) + return +} + // Watch returns a watch.Interface that watches the requested certificateSigningRequests. func (c *certificateSigningRequests) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { var timeout time.Duration diff --git a/staging/src/k8s.io/client-go/kubernetes/typed/coordination/v1/lease.go b/staging/src/k8s.io/client-go/kubernetes/typed/coordination/v1/lease.go index 032787c672c..669f8548cd0 100644 --- a/staging/src/k8s.io/client-go/kubernetes/typed/coordination/v1/lease.go +++ b/staging/src/k8s.io/client-go/kubernetes/typed/coordination/v1/lease.go @@ -32,6 +32,8 @@ import ( scheme "k8s.io/client-go/kubernetes/scheme" rest "k8s.io/client-go/rest" consistencydetector "k8s.io/client-go/util/consistencydetector" + watchlist "k8s.io/client-go/util/watchlist" + "k8s.io/klog/v2" ) // LeasesGetter has a method to return a LeaseInterface. @@ -82,13 +84,22 @@ func (c *leases) Get(ctx context.Context, name string, options metav1.GetOptions } // List takes label and field selectors, and returns the list of Leases that match those selectors. -func (c *leases) List(ctx context.Context, opts metav1.ListOptions) (result *v1.LeaseList, err error) { - defer func() { +func (c *leases) List(ctx context.Context, opts metav1.ListOptions) (*v1.LeaseList, error) { + if watchListOptions, hasWatchListOptionsPrepared, watchListOptionsErr := watchlist.PrepareWatchListOptionsFromListOptions(opts); watchListOptionsErr != nil { + klog.Warningf("Failed preparing watchlist options for leases, falling back to the standard LIST semantics, err = %v", watchListOptionsErr) + } else if hasWatchListOptionsPrepared { + result, err := c.watchList(ctx, watchListOptions) if err == nil { - consistencydetector.CheckListFromCacheDataConsistencyIfRequested(ctx, "list request for leases", c.list, opts, result) + consistencydetector.CheckWatchListFromCacheDataConsistencyIfRequested(ctx, "watchlist request for leases", c.list, opts, result) + return result, nil } - }() - return c.list(ctx, opts) + klog.Warningf("The watchlist request for leases ended with an error, falling back to the standard LIST semantics, err = %v", err) + } + result, err := c.list(ctx, opts) + if err == nil { + consistencydetector.CheckListFromCacheDataConsistencyIfRequested(ctx, "list request for leases", c.list, opts, result) + } + return result, err } // list takes label and field selectors, and returns the list of Leases that match those selectors. @@ -108,6 +119,23 @@ func (c *leases) list(ctx context.Context, opts metav1.ListOptions) (result *v1. return } +// watchList establishes a watch stream with the server and returns the list of Leases +func (c *leases) watchList(ctx context.Context, opts metav1.ListOptions) (result *v1.LeaseList, err error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + result = &v1.LeaseList{} + err = c.client.Get(). + Namespace(c.ns). + Resource("leases"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + WatchList(ctx). + Into(result) + return +} + // Watch returns a watch.Interface that watches the requested leases. func (c *leases) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { var timeout time.Duration diff --git a/staging/src/k8s.io/client-go/kubernetes/typed/coordination/v1beta1/lease.go b/staging/src/k8s.io/client-go/kubernetes/typed/coordination/v1beta1/lease.go index e6841ffd98e..4a990053b00 100644 --- a/staging/src/k8s.io/client-go/kubernetes/typed/coordination/v1beta1/lease.go +++ b/staging/src/k8s.io/client-go/kubernetes/typed/coordination/v1beta1/lease.go @@ -32,6 +32,8 @@ import ( scheme "k8s.io/client-go/kubernetes/scheme" rest "k8s.io/client-go/rest" consistencydetector "k8s.io/client-go/util/consistencydetector" + watchlist "k8s.io/client-go/util/watchlist" + "k8s.io/klog/v2" ) // LeasesGetter has a method to return a LeaseInterface. @@ -82,13 +84,22 @@ func (c *leases) Get(ctx context.Context, name string, options v1.GetOptions) (r } // List takes label and field selectors, and returns the list of Leases that match those selectors. -func (c *leases) List(ctx context.Context, opts v1.ListOptions) (result *v1beta1.LeaseList, err error) { - defer func() { +func (c *leases) List(ctx context.Context, opts v1.ListOptions) (*v1beta1.LeaseList, error) { + if watchListOptions, hasWatchListOptionsPrepared, watchListOptionsErr := watchlist.PrepareWatchListOptionsFromListOptions(opts); watchListOptionsErr != nil { + klog.Warningf("Failed preparing watchlist options for leases, falling back to the standard LIST semantics, err = %v", watchListOptionsErr) + } else if hasWatchListOptionsPrepared { + result, err := c.watchList(ctx, watchListOptions) if err == nil { - consistencydetector.CheckListFromCacheDataConsistencyIfRequested(ctx, "list request for leases", c.list, opts, result) + consistencydetector.CheckWatchListFromCacheDataConsistencyIfRequested(ctx, "watchlist request for leases", c.list, opts, result) + return result, nil } - }() - return c.list(ctx, opts) + klog.Warningf("The watchlist request for leases ended with an error, falling back to the standard LIST semantics, err = %v", err) + } + result, err := c.list(ctx, opts) + if err == nil { + consistencydetector.CheckListFromCacheDataConsistencyIfRequested(ctx, "list request for leases", c.list, opts, result) + } + return result, err } // list takes label and field selectors, and returns the list of Leases that match those selectors. @@ -108,6 +119,23 @@ func (c *leases) list(ctx context.Context, opts v1.ListOptions) (result *v1beta1 return } +// watchList establishes a watch stream with the server and returns the list of Leases +func (c *leases) watchList(ctx context.Context, opts v1.ListOptions) (result *v1beta1.LeaseList, err error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + result = &v1beta1.LeaseList{} + err = c.client.Get(). + Namespace(c.ns). + Resource("leases"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + WatchList(ctx). + Into(result) + return +} + // Watch returns a watch.Interface that watches the requested leases. func (c *leases) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { var timeout time.Duration diff --git a/staging/src/k8s.io/client-go/kubernetes/typed/core/v1/componentstatus.go b/staging/src/k8s.io/client-go/kubernetes/typed/core/v1/componentstatus.go index f2ea72e4660..de958c6e916 100644 --- a/staging/src/k8s.io/client-go/kubernetes/typed/core/v1/componentstatus.go +++ b/staging/src/k8s.io/client-go/kubernetes/typed/core/v1/componentstatus.go @@ -32,6 +32,8 @@ import ( scheme "k8s.io/client-go/kubernetes/scheme" rest "k8s.io/client-go/rest" consistencydetector "k8s.io/client-go/util/consistencydetector" + watchlist "k8s.io/client-go/util/watchlist" + "k8s.io/klog/v2" ) // ComponentStatusesGetter has a method to return a ComponentStatusInterface. @@ -79,13 +81,22 @@ func (c *componentStatuses) Get(ctx context.Context, name string, options metav1 } // List takes label and field selectors, and returns the list of ComponentStatuses that match those selectors. -func (c *componentStatuses) List(ctx context.Context, opts metav1.ListOptions) (result *v1.ComponentStatusList, err error) { - defer func() { +func (c *componentStatuses) List(ctx context.Context, opts metav1.ListOptions) (*v1.ComponentStatusList, error) { + if watchListOptions, hasWatchListOptionsPrepared, watchListOptionsErr := watchlist.PrepareWatchListOptionsFromListOptions(opts); watchListOptionsErr != nil { + klog.Warningf("Failed preparing watchlist options for componentstatuses, falling back to the standard LIST semantics, err = %v", watchListOptionsErr) + } else if hasWatchListOptionsPrepared { + result, err := c.watchList(ctx, watchListOptions) if err == nil { - consistencydetector.CheckListFromCacheDataConsistencyIfRequested(ctx, "list request for componentstatuses", c.list, opts, result) + consistencydetector.CheckWatchListFromCacheDataConsistencyIfRequested(ctx, "watchlist request for componentstatuses", c.list, opts, result) + return result, nil } - }() - return c.list(ctx, opts) + klog.Warningf("The watchlist request for componentstatuses ended with an error, falling back to the standard LIST semantics, err = %v", err) + } + result, err := c.list(ctx, opts) + if err == nil { + consistencydetector.CheckListFromCacheDataConsistencyIfRequested(ctx, "list request for componentstatuses", c.list, opts, result) + } + return result, err } // list takes label and field selectors, and returns the list of ComponentStatuses that match those selectors. @@ -104,6 +115,22 @@ func (c *componentStatuses) list(ctx context.Context, opts metav1.ListOptions) ( return } +// watchList establishes a watch stream with the server and returns the list of ComponentStatuses +func (c *componentStatuses) watchList(ctx context.Context, opts metav1.ListOptions) (result *v1.ComponentStatusList, err error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + result = &v1.ComponentStatusList{} + err = c.client.Get(). + Resource("componentstatuses"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + WatchList(ctx). + Into(result) + return +} + // Watch returns a watch.Interface that watches the requested componentStatuses. func (c *componentStatuses) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { var timeout time.Duration diff --git a/staging/src/k8s.io/client-go/kubernetes/typed/core/v1/configmap.go b/staging/src/k8s.io/client-go/kubernetes/typed/core/v1/configmap.go index 27d19b8bd3e..916786d5395 100644 --- a/staging/src/k8s.io/client-go/kubernetes/typed/core/v1/configmap.go +++ b/staging/src/k8s.io/client-go/kubernetes/typed/core/v1/configmap.go @@ -32,6 +32,8 @@ import ( scheme "k8s.io/client-go/kubernetes/scheme" rest "k8s.io/client-go/rest" consistencydetector "k8s.io/client-go/util/consistencydetector" + watchlist "k8s.io/client-go/util/watchlist" + "k8s.io/klog/v2" ) // ConfigMapsGetter has a method to return a ConfigMapInterface. @@ -82,13 +84,22 @@ func (c *configMaps) Get(ctx context.Context, name string, options metav1.GetOpt } // List takes label and field selectors, and returns the list of ConfigMaps that match those selectors. -func (c *configMaps) List(ctx context.Context, opts metav1.ListOptions) (result *v1.ConfigMapList, err error) { - defer func() { +func (c *configMaps) List(ctx context.Context, opts metav1.ListOptions) (*v1.ConfigMapList, error) { + if watchListOptions, hasWatchListOptionsPrepared, watchListOptionsErr := watchlist.PrepareWatchListOptionsFromListOptions(opts); watchListOptionsErr != nil { + klog.Warningf("Failed preparing watchlist options for configmaps, falling back to the standard LIST semantics, err = %v", watchListOptionsErr) + } else if hasWatchListOptionsPrepared { + result, err := c.watchList(ctx, watchListOptions) if err == nil { - consistencydetector.CheckListFromCacheDataConsistencyIfRequested(ctx, "list request for configmaps", c.list, opts, result) + consistencydetector.CheckWatchListFromCacheDataConsistencyIfRequested(ctx, "watchlist request for configmaps", c.list, opts, result) + return result, nil } - }() - return c.list(ctx, opts) + klog.Warningf("The watchlist request for configmaps ended with an error, falling back to the standard LIST semantics, err = %v", err) + } + result, err := c.list(ctx, opts) + if err == nil { + consistencydetector.CheckListFromCacheDataConsistencyIfRequested(ctx, "list request for configmaps", c.list, opts, result) + } + return result, err } // list takes label and field selectors, and returns the list of ConfigMaps that match those selectors. @@ -108,6 +119,23 @@ func (c *configMaps) list(ctx context.Context, opts metav1.ListOptions) (result return } +// watchList establishes a watch stream with the server and returns the list of ConfigMaps +func (c *configMaps) watchList(ctx context.Context, opts metav1.ListOptions) (result *v1.ConfigMapList, err error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + result = &v1.ConfigMapList{} + err = c.client.Get(). + Namespace(c.ns). + Resource("configmaps"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + WatchList(ctx). + Into(result) + return +} + // Watch returns a watch.Interface that watches the requested configMaps. func (c *configMaps) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { var timeout time.Duration diff --git a/staging/src/k8s.io/client-go/kubernetes/typed/core/v1/endpoints.go b/staging/src/k8s.io/client-go/kubernetes/typed/core/v1/endpoints.go index cf811572baf..02a87b53200 100644 --- a/staging/src/k8s.io/client-go/kubernetes/typed/core/v1/endpoints.go +++ b/staging/src/k8s.io/client-go/kubernetes/typed/core/v1/endpoints.go @@ -32,6 +32,8 @@ import ( scheme "k8s.io/client-go/kubernetes/scheme" rest "k8s.io/client-go/rest" consistencydetector "k8s.io/client-go/util/consistencydetector" + watchlist "k8s.io/client-go/util/watchlist" + "k8s.io/klog/v2" ) // EndpointsGetter has a method to return a EndpointsInterface. @@ -82,13 +84,22 @@ func (c *endpoints) Get(ctx context.Context, name string, options metav1.GetOpti } // List takes label and field selectors, and returns the list of Endpoints that match those selectors. -func (c *endpoints) List(ctx context.Context, opts metav1.ListOptions) (result *v1.EndpointsList, err error) { - defer func() { +func (c *endpoints) List(ctx context.Context, opts metav1.ListOptions) (*v1.EndpointsList, error) { + if watchListOptions, hasWatchListOptionsPrepared, watchListOptionsErr := watchlist.PrepareWatchListOptionsFromListOptions(opts); watchListOptionsErr != nil { + klog.Warningf("Failed preparing watchlist options for endpoints, falling back to the standard LIST semantics, err = %v", watchListOptionsErr) + } else if hasWatchListOptionsPrepared { + result, err := c.watchList(ctx, watchListOptions) if err == nil { - consistencydetector.CheckListFromCacheDataConsistencyIfRequested(ctx, "list request for endpoints", c.list, opts, result) + consistencydetector.CheckWatchListFromCacheDataConsistencyIfRequested(ctx, "watchlist request for endpoints", c.list, opts, result) + return result, nil } - }() - return c.list(ctx, opts) + klog.Warningf("The watchlist request for endpoints ended with an error, falling back to the standard LIST semantics, err = %v", err) + } + result, err := c.list(ctx, opts) + if err == nil { + consistencydetector.CheckListFromCacheDataConsistencyIfRequested(ctx, "list request for endpoints", c.list, opts, result) + } + return result, err } // list takes label and field selectors, and returns the list of Endpoints that match those selectors. @@ -108,6 +119,23 @@ func (c *endpoints) list(ctx context.Context, opts metav1.ListOptions) (result * return } +// watchList establishes a watch stream with the server and returns the list of Endpoints +func (c *endpoints) watchList(ctx context.Context, opts metav1.ListOptions) (result *v1.EndpointsList, err error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + result = &v1.EndpointsList{} + err = c.client.Get(). + Namespace(c.ns). + Resource("endpoints"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + WatchList(ctx). + Into(result) + return +} + // Watch returns a watch.Interface that watches the requested endpoints. func (c *endpoints) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { var timeout time.Duration diff --git a/staging/src/k8s.io/client-go/kubernetes/typed/core/v1/event.go b/staging/src/k8s.io/client-go/kubernetes/typed/core/v1/event.go index 9873dbdb08e..d045c99f327 100644 --- a/staging/src/k8s.io/client-go/kubernetes/typed/core/v1/event.go +++ b/staging/src/k8s.io/client-go/kubernetes/typed/core/v1/event.go @@ -32,6 +32,8 @@ import ( scheme "k8s.io/client-go/kubernetes/scheme" rest "k8s.io/client-go/rest" consistencydetector "k8s.io/client-go/util/consistencydetector" + watchlist "k8s.io/client-go/util/watchlist" + "k8s.io/klog/v2" ) // EventsGetter has a method to return a EventInterface. @@ -82,13 +84,22 @@ func (c *events) Get(ctx context.Context, name string, options metav1.GetOptions } // List takes label and field selectors, and returns the list of Events that match those selectors. -func (c *events) List(ctx context.Context, opts metav1.ListOptions) (result *v1.EventList, err error) { - defer func() { +func (c *events) List(ctx context.Context, opts metav1.ListOptions) (*v1.EventList, error) { + if watchListOptions, hasWatchListOptionsPrepared, watchListOptionsErr := watchlist.PrepareWatchListOptionsFromListOptions(opts); watchListOptionsErr != nil { + klog.Warningf("Failed preparing watchlist options for events, falling back to the standard LIST semantics, err = %v", watchListOptionsErr) + } else if hasWatchListOptionsPrepared { + result, err := c.watchList(ctx, watchListOptions) if err == nil { - consistencydetector.CheckListFromCacheDataConsistencyIfRequested(ctx, "list request for events", c.list, opts, result) + consistencydetector.CheckWatchListFromCacheDataConsistencyIfRequested(ctx, "watchlist request for events", c.list, opts, result) + return result, nil } - }() - return c.list(ctx, opts) + klog.Warningf("The watchlist request for events ended with an error, falling back to the standard LIST semantics, err = %v", err) + } + result, err := c.list(ctx, opts) + if err == nil { + consistencydetector.CheckListFromCacheDataConsistencyIfRequested(ctx, "list request for events", c.list, opts, result) + } + return result, err } // list takes label and field selectors, and returns the list of Events that match those selectors. @@ -108,6 +119,23 @@ func (c *events) list(ctx context.Context, opts metav1.ListOptions) (result *v1. return } +// watchList establishes a watch stream with the server and returns the list of Events +func (c *events) watchList(ctx context.Context, opts metav1.ListOptions) (result *v1.EventList, err error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + result = &v1.EventList{} + err = c.client.Get(). + Namespace(c.ns). + Resource("events"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + WatchList(ctx). + Into(result) + return +} + // Watch returns a watch.Interface that watches the requested events. func (c *events) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { var timeout time.Duration diff --git a/staging/src/k8s.io/client-go/kubernetes/typed/core/v1/limitrange.go b/staging/src/k8s.io/client-go/kubernetes/typed/core/v1/limitrange.go index 92f6b2f545d..e5f54e1f660 100644 --- a/staging/src/k8s.io/client-go/kubernetes/typed/core/v1/limitrange.go +++ b/staging/src/k8s.io/client-go/kubernetes/typed/core/v1/limitrange.go @@ -32,6 +32,8 @@ import ( scheme "k8s.io/client-go/kubernetes/scheme" rest "k8s.io/client-go/rest" consistencydetector "k8s.io/client-go/util/consistencydetector" + watchlist "k8s.io/client-go/util/watchlist" + "k8s.io/klog/v2" ) // LimitRangesGetter has a method to return a LimitRangeInterface. @@ -82,13 +84,22 @@ func (c *limitRanges) Get(ctx context.Context, name string, options metav1.GetOp } // List takes label and field selectors, and returns the list of LimitRanges that match those selectors. -func (c *limitRanges) List(ctx context.Context, opts metav1.ListOptions) (result *v1.LimitRangeList, err error) { - defer func() { +func (c *limitRanges) List(ctx context.Context, opts metav1.ListOptions) (*v1.LimitRangeList, error) { + if watchListOptions, hasWatchListOptionsPrepared, watchListOptionsErr := watchlist.PrepareWatchListOptionsFromListOptions(opts); watchListOptionsErr != nil { + klog.Warningf("Failed preparing watchlist options for limitranges, falling back to the standard LIST semantics, err = %v", watchListOptionsErr) + } else if hasWatchListOptionsPrepared { + result, err := c.watchList(ctx, watchListOptions) if err == nil { - consistencydetector.CheckListFromCacheDataConsistencyIfRequested(ctx, "list request for limitranges", c.list, opts, result) + consistencydetector.CheckWatchListFromCacheDataConsistencyIfRequested(ctx, "watchlist request for limitranges", c.list, opts, result) + return result, nil } - }() - return c.list(ctx, opts) + klog.Warningf("The watchlist request for limitranges ended with an error, falling back to the standard LIST semantics, err = %v", err) + } + result, err := c.list(ctx, opts) + if err == nil { + consistencydetector.CheckListFromCacheDataConsistencyIfRequested(ctx, "list request for limitranges", c.list, opts, result) + } + return result, err } // list takes label and field selectors, and returns the list of LimitRanges that match those selectors. @@ -108,6 +119,23 @@ func (c *limitRanges) list(ctx context.Context, opts metav1.ListOptions) (result return } +// watchList establishes a watch stream with the server and returns the list of LimitRanges +func (c *limitRanges) watchList(ctx context.Context, opts metav1.ListOptions) (result *v1.LimitRangeList, err error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + result = &v1.LimitRangeList{} + err = c.client.Get(). + Namespace(c.ns). + Resource("limitranges"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + WatchList(ctx). + Into(result) + return +} + // Watch returns a watch.Interface that watches the requested limitRanges. func (c *limitRanges) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { var timeout time.Duration diff --git a/staging/src/k8s.io/client-go/kubernetes/typed/core/v1/namespace.go b/staging/src/k8s.io/client-go/kubernetes/typed/core/v1/namespace.go index 709d53ad859..6d430cf99a5 100644 --- a/staging/src/k8s.io/client-go/kubernetes/typed/core/v1/namespace.go +++ b/staging/src/k8s.io/client-go/kubernetes/typed/core/v1/namespace.go @@ -32,6 +32,8 @@ import ( scheme "k8s.io/client-go/kubernetes/scheme" rest "k8s.io/client-go/rest" consistencydetector "k8s.io/client-go/util/consistencydetector" + watchlist "k8s.io/client-go/util/watchlist" + "k8s.io/klog/v2" ) // NamespacesGetter has a method to return a NamespaceInterface. @@ -80,13 +82,22 @@ func (c *namespaces) Get(ctx context.Context, name string, options metav1.GetOpt } // List takes label and field selectors, and returns the list of Namespaces that match those selectors. -func (c *namespaces) List(ctx context.Context, opts metav1.ListOptions) (result *v1.NamespaceList, err error) { - defer func() { +func (c *namespaces) List(ctx context.Context, opts metav1.ListOptions) (*v1.NamespaceList, error) { + if watchListOptions, hasWatchListOptionsPrepared, watchListOptionsErr := watchlist.PrepareWatchListOptionsFromListOptions(opts); watchListOptionsErr != nil { + klog.Warningf("Failed preparing watchlist options for namespaces, falling back to the standard LIST semantics, err = %v", watchListOptionsErr) + } else if hasWatchListOptionsPrepared { + result, err := c.watchList(ctx, watchListOptions) if err == nil { - consistencydetector.CheckListFromCacheDataConsistencyIfRequested(ctx, "list request for namespaces", c.list, opts, result) + consistencydetector.CheckWatchListFromCacheDataConsistencyIfRequested(ctx, "watchlist request for namespaces", c.list, opts, result) + return result, nil } - }() - return c.list(ctx, opts) + klog.Warningf("The watchlist request for namespaces ended with an error, falling back to the standard LIST semantics, err = %v", err) + } + result, err := c.list(ctx, opts) + if err == nil { + consistencydetector.CheckListFromCacheDataConsistencyIfRequested(ctx, "list request for namespaces", c.list, opts, result) + } + return result, err } // list takes label and field selectors, and returns the list of Namespaces that match those selectors. @@ -105,6 +116,22 @@ func (c *namespaces) list(ctx context.Context, opts metav1.ListOptions) (result return } +// watchList establishes a watch stream with the server and returns the list of Namespaces +func (c *namespaces) watchList(ctx context.Context, opts metav1.ListOptions) (result *v1.NamespaceList, err error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + result = &v1.NamespaceList{} + err = c.client.Get(). + Resource("namespaces"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + WatchList(ctx). + Into(result) + return +} + // Watch returns a watch.Interface that watches the requested namespaces. func (c *namespaces) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { var timeout time.Duration diff --git a/staging/src/k8s.io/client-go/kubernetes/typed/core/v1/node.go b/staging/src/k8s.io/client-go/kubernetes/typed/core/v1/node.go index 4a4fc825cc9..a3ea2a8a93e 100644 --- a/staging/src/k8s.io/client-go/kubernetes/typed/core/v1/node.go +++ b/staging/src/k8s.io/client-go/kubernetes/typed/core/v1/node.go @@ -32,6 +32,8 @@ import ( scheme "k8s.io/client-go/kubernetes/scheme" rest "k8s.io/client-go/rest" consistencydetector "k8s.io/client-go/util/consistencydetector" + watchlist "k8s.io/client-go/util/watchlist" + "k8s.io/klog/v2" ) // NodesGetter has a method to return a NodeInterface. @@ -81,13 +83,22 @@ func (c *nodes) Get(ctx context.Context, name string, options metav1.GetOptions) } // List takes label and field selectors, and returns the list of Nodes that match those selectors. -func (c *nodes) List(ctx context.Context, opts metav1.ListOptions) (result *v1.NodeList, err error) { - defer func() { +func (c *nodes) List(ctx context.Context, opts metav1.ListOptions) (*v1.NodeList, error) { + if watchListOptions, hasWatchListOptionsPrepared, watchListOptionsErr := watchlist.PrepareWatchListOptionsFromListOptions(opts); watchListOptionsErr != nil { + klog.Warningf("Failed preparing watchlist options for nodes, falling back to the standard LIST semantics, err = %v", watchListOptionsErr) + } else if hasWatchListOptionsPrepared { + result, err := c.watchList(ctx, watchListOptions) if err == nil { - consistencydetector.CheckListFromCacheDataConsistencyIfRequested(ctx, "list request for nodes", c.list, opts, result) + consistencydetector.CheckWatchListFromCacheDataConsistencyIfRequested(ctx, "watchlist request for nodes", c.list, opts, result) + return result, nil } - }() - return c.list(ctx, opts) + klog.Warningf("The watchlist request for nodes ended with an error, falling back to the standard LIST semantics, err = %v", err) + } + result, err := c.list(ctx, opts) + if err == nil { + consistencydetector.CheckListFromCacheDataConsistencyIfRequested(ctx, "list request for nodes", c.list, opts, result) + } + return result, err } // list takes label and field selectors, and returns the list of Nodes that match those selectors. @@ -106,6 +117,22 @@ func (c *nodes) list(ctx context.Context, opts metav1.ListOptions) (result *v1.N return } +// watchList establishes a watch stream with the server and returns the list of Nodes +func (c *nodes) watchList(ctx context.Context, opts metav1.ListOptions) (result *v1.NodeList, err error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + result = &v1.NodeList{} + err = c.client.Get(). + Resource("nodes"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + WatchList(ctx). + Into(result) + return +} + // Watch returns a watch.Interface that watches the requested nodes. func (c *nodes) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { var timeout time.Duration diff --git a/staging/src/k8s.io/client-go/kubernetes/typed/core/v1/persistentvolume.go b/staging/src/k8s.io/client-go/kubernetes/typed/core/v1/persistentvolume.go index 63442dd9b00..c252330543e 100644 --- a/staging/src/k8s.io/client-go/kubernetes/typed/core/v1/persistentvolume.go +++ b/staging/src/k8s.io/client-go/kubernetes/typed/core/v1/persistentvolume.go @@ -32,6 +32,8 @@ import ( scheme "k8s.io/client-go/kubernetes/scheme" rest "k8s.io/client-go/rest" consistencydetector "k8s.io/client-go/util/consistencydetector" + watchlist "k8s.io/client-go/util/watchlist" + "k8s.io/klog/v2" ) // PersistentVolumesGetter has a method to return a PersistentVolumeInterface. @@ -81,13 +83,22 @@ func (c *persistentVolumes) Get(ctx context.Context, name string, options metav1 } // List takes label and field selectors, and returns the list of PersistentVolumes that match those selectors. -func (c *persistentVolumes) List(ctx context.Context, opts metav1.ListOptions) (result *v1.PersistentVolumeList, err error) { - defer func() { +func (c *persistentVolumes) List(ctx context.Context, opts metav1.ListOptions) (*v1.PersistentVolumeList, error) { + if watchListOptions, hasWatchListOptionsPrepared, watchListOptionsErr := watchlist.PrepareWatchListOptionsFromListOptions(opts); watchListOptionsErr != nil { + klog.Warningf("Failed preparing watchlist options for persistentvolumes, falling back to the standard LIST semantics, err = %v", watchListOptionsErr) + } else if hasWatchListOptionsPrepared { + result, err := c.watchList(ctx, watchListOptions) if err == nil { - consistencydetector.CheckListFromCacheDataConsistencyIfRequested(ctx, "list request for persistentvolumes", c.list, opts, result) + consistencydetector.CheckWatchListFromCacheDataConsistencyIfRequested(ctx, "watchlist request for persistentvolumes", c.list, opts, result) + return result, nil } - }() - return c.list(ctx, opts) + klog.Warningf("The watchlist request for persistentvolumes ended with an error, falling back to the standard LIST semantics, err = %v", err) + } + result, err := c.list(ctx, opts) + if err == nil { + consistencydetector.CheckListFromCacheDataConsistencyIfRequested(ctx, "list request for persistentvolumes", c.list, opts, result) + } + return result, err } // list takes label and field selectors, and returns the list of PersistentVolumes that match those selectors. @@ -106,6 +117,22 @@ func (c *persistentVolumes) list(ctx context.Context, opts metav1.ListOptions) ( return } +// watchList establishes a watch stream with the server and returns the list of PersistentVolumes +func (c *persistentVolumes) watchList(ctx context.Context, opts metav1.ListOptions) (result *v1.PersistentVolumeList, err error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + result = &v1.PersistentVolumeList{} + err = c.client.Get(). + Resource("persistentvolumes"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + WatchList(ctx). + Into(result) + return +} + // Watch returns a watch.Interface that watches the requested persistentVolumes. func (c *persistentVolumes) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { var timeout time.Duration diff --git a/staging/src/k8s.io/client-go/kubernetes/typed/core/v1/persistentvolumeclaim.go b/staging/src/k8s.io/client-go/kubernetes/typed/core/v1/persistentvolumeclaim.go index 3b3c61c6b77..a3182406420 100644 --- a/staging/src/k8s.io/client-go/kubernetes/typed/core/v1/persistentvolumeclaim.go +++ b/staging/src/k8s.io/client-go/kubernetes/typed/core/v1/persistentvolumeclaim.go @@ -32,6 +32,8 @@ import ( scheme "k8s.io/client-go/kubernetes/scheme" rest "k8s.io/client-go/rest" consistencydetector "k8s.io/client-go/util/consistencydetector" + watchlist "k8s.io/client-go/util/watchlist" + "k8s.io/klog/v2" ) // PersistentVolumeClaimsGetter has a method to return a PersistentVolumeClaimInterface. @@ -84,13 +86,22 @@ func (c *persistentVolumeClaims) Get(ctx context.Context, name string, options m } // List takes label and field selectors, and returns the list of PersistentVolumeClaims that match those selectors. -func (c *persistentVolumeClaims) List(ctx context.Context, opts metav1.ListOptions) (result *v1.PersistentVolumeClaimList, err error) { - defer func() { +func (c *persistentVolumeClaims) List(ctx context.Context, opts metav1.ListOptions) (*v1.PersistentVolumeClaimList, error) { + if watchListOptions, hasWatchListOptionsPrepared, watchListOptionsErr := watchlist.PrepareWatchListOptionsFromListOptions(opts); watchListOptionsErr != nil { + klog.Warningf("Failed preparing watchlist options for persistentvolumeclaims, falling back to the standard LIST semantics, err = %v", watchListOptionsErr) + } else if hasWatchListOptionsPrepared { + result, err := c.watchList(ctx, watchListOptions) if err == nil { - consistencydetector.CheckListFromCacheDataConsistencyIfRequested(ctx, "list request for persistentvolumeclaims", c.list, opts, result) + consistencydetector.CheckWatchListFromCacheDataConsistencyIfRequested(ctx, "watchlist request for persistentvolumeclaims", c.list, opts, result) + return result, nil } - }() - return c.list(ctx, opts) + klog.Warningf("The watchlist request for persistentvolumeclaims ended with an error, falling back to the standard LIST semantics, err = %v", err) + } + result, err := c.list(ctx, opts) + if err == nil { + consistencydetector.CheckListFromCacheDataConsistencyIfRequested(ctx, "list request for persistentvolumeclaims", c.list, opts, result) + } + return result, err } // list takes label and field selectors, and returns the list of PersistentVolumeClaims that match those selectors. @@ -110,6 +121,23 @@ func (c *persistentVolumeClaims) list(ctx context.Context, opts metav1.ListOptio return } +// watchList establishes a watch stream with the server and returns the list of PersistentVolumeClaims +func (c *persistentVolumeClaims) watchList(ctx context.Context, opts metav1.ListOptions) (result *v1.PersistentVolumeClaimList, err error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + result = &v1.PersistentVolumeClaimList{} + err = c.client.Get(). + Namespace(c.ns). + Resource("persistentvolumeclaims"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + WatchList(ctx). + Into(result) + return +} + // Watch returns a watch.Interface that watches the requested persistentVolumeClaims. func (c *persistentVolumeClaims) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { var timeout time.Duration diff --git a/staging/src/k8s.io/client-go/kubernetes/typed/core/v1/pod.go b/staging/src/k8s.io/client-go/kubernetes/typed/core/v1/pod.go index a275bd2c78e..23f80160a0e 100644 --- a/staging/src/k8s.io/client-go/kubernetes/typed/core/v1/pod.go +++ b/staging/src/k8s.io/client-go/kubernetes/typed/core/v1/pod.go @@ -32,6 +32,8 @@ import ( scheme "k8s.io/client-go/kubernetes/scheme" rest "k8s.io/client-go/rest" consistencydetector "k8s.io/client-go/util/consistencydetector" + watchlist "k8s.io/client-go/util/watchlist" + "k8s.io/klog/v2" ) // PodsGetter has a method to return a PodInterface. @@ -86,13 +88,22 @@ func (c *pods) Get(ctx context.Context, name string, options metav1.GetOptions) } // List takes label and field selectors, and returns the list of Pods that match those selectors. -func (c *pods) List(ctx context.Context, opts metav1.ListOptions) (result *v1.PodList, err error) { - defer func() { +func (c *pods) List(ctx context.Context, opts metav1.ListOptions) (*v1.PodList, error) { + if watchListOptions, hasWatchListOptionsPrepared, watchListOptionsErr := watchlist.PrepareWatchListOptionsFromListOptions(opts); watchListOptionsErr != nil { + klog.Warningf("Failed preparing watchlist options for pods, falling back to the standard LIST semantics, err = %v", watchListOptionsErr) + } else if hasWatchListOptionsPrepared { + result, err := c.watchList(ctx, watchListOptions) if err == nil { - consistencydetector.CheckListFromCacheDataConsistencyIfRequested(ctx, "list request for pods", c.list, opts, result) + consistencydetector.CheckWatchListFromCacheDataConsistencyIfRequested(ctx, "watchlist request for pods", c.list, opts, result) + return result, nil } - }() - return c.list(ctx, opts) + klog.Warningf("The watchlist request for pods ended with an error, falling back to the standard LIST semantics, err = %v", err) + } + result, err := c.list(ctx, opts) + if err == nil { + consistencydetector.CheckListFromCacheDataConsistencyIfRequested(ctx, "list request for pods", c.list, opts, result) + } + return result, err } // list takes label and field selectors, and returns the list of Pods that match those selectors. @@ -112,6 +123,23 @@ func (c *pods) list(ctx context.Context, opts metav1.ListOptions) (result *v1.Po return } +// watchList establishes a watch stream with the server and returns the list of Pods +func (c *pods) watchList(ctx context.Context, opts metav1.ListOptions) (result *v1.PodList, err error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + result = &v1.PodList{} + err = c.client.Get(). + Namespace(c.ns). + Resource("pods"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + WatchList(ctx). + Into(result) + return +} + // Watch returns a watch.Interface that watches the requested pods. func (c *pods) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { var timeout time.Duration diff --git a/staging/src/k8s.io/client-go/kubernetes/typed/core/v1/podtemplate.go b/staging/src/k8s.io/client-go/kubernetes/typed/core/v1/podtemplate.go index f657046535a..47f358809c4 100644 --- a/staging/src/k8s.io/client-go/kubernetes/typed/core/v1/podtemplate.go +++ b/staging/src/k8s.io/client-go/kubernetes/typed/core/v1/podtemplate.go @@ -32,6 +32,8 @@ import ( scheme "k8s.io/client-go/kubernetes/scheme" rest "k8s.io/client-go/rest" consistencydetector "k8s.io/client-go/util/consistencydetector" + watchlist "k8s.io/client-go/util/watchlist" + "k8s.io/klog/v2" ) // PodTemplatesGetter has a method to return a PodTemplateInterface. @@ -82,13 +84,22 @@ func (c *podTemplates) Get(ctx context.Context, name string, options metav1.GetO } // List takes label and field selectors, and returns the list of PodTemplates that match those selectors. -func (c *podTemplates) List(ctx context.Context, opts metav1.ListOptions) (result *v1.PodTemplateList, err error) { - defer func() { +func (c *podTemplates) List(ctx context.Context, opts metav1.ListOptions) (*v1.PodTemplateList, error) { + if watchListOptions, hasWatchListOptionsPrepared, watchListOptionsErr := watchlist.PrepareWatchListOptionsFromListOptions(opts); watchListOptionsErr != nil { + klog.Warningf("Failed preparing watchlist options for podtemplates, falling back to the standard LIST semantics, err = %v", watchListOptionsErr) + } else if hasWatchListOptionsPrepared { + result, err := c.watchList(ctx, watchListOptions) if err == nil { - consistencydetector.CheckListFromCacheDataConsistencyIfRequested(ctx, "list request for podtemplates", c.list, opts, result) + consistencydetector.CheckWatchListFromCacheDataConsistencyIfRequested(ctx, "watchlist request for podtemplates", c.list, opts, result) + return result, nil } - }() - return c.list(ctx, opts) + klog.Warningf("The watchlist request for podtemplates ended with an error, falling back to the standard LIST semantics, err = %v", err) + } + result, err := c.list(ctx, opts) + if err == nil { + consistencydetector.CheckListFromCacheDataConsistencyIfRequested(ctx, "list request for podtemplates", c.list, opts, result) + } + return result, err } // list takes label and field selectors, and returns the list of PodTemplates that match those selectors. @@ -108,6 +119,23 @@ func (c *podTemplates) list(ctx context.Context, opts metav1.ListOptions) (resul return } +// watchList establishes a watch stream with the server and returns the list of PodTemplates +func (c *podTemplates) watchList(ctx context.Context, opts metav1.ListOptions) (result *v1.PodTemplateList, err error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + result = &v1.PodTemplateList{} + err = c.client.Get(). + Namespace(c.ns). + Resource("podtemplates"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + WatchList(ctx). + Into(result) + return +} + // Watch returns a watch.Interface that watches the requested podTemplates. func (c *podTemplates) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { var timeout time.Duration diff --git a/staging/src/k8s.io/client-go/kubernetes/typed/core/v1/replicationcontroller.go b/staging/src/k8s.io/client-go/kubernetes/typed/core/v1/replicationcontroller.go index 1ff2371f1ec..d7c48513752 100644 --- a/staging/src/k8s.io/client-go/kubernetes/typed/core/v1/replicationcontroller.go +++ b/staging/src/k8s.io/client-go/kubernetes/typed/core/v1/replicationcontroller.go @@ -33,6 +33,8 @@ import ( scheme "k8s.io/client-go/kubernetes/scheme" rest "k8s.io/client-go/rest" consistencydetector "k8s.io/client-go/util/consistencydetector" + watchlist "k8s.io/client-go/util/watchlist" + "k8s.io/klog/v2" ) // ReplicationControllersGetter has a method to return a ReplicationControllerInterface. @@ -88,13 +90,22 @@ func (c *replicationControllers) Get(ctx context.Context, name string, options m } // List takes label and field selectors, and returns the list of ReplicationControllers that match those selectors. -func (c *replicationControllers) List(ctx context.Context, opts metav1.ListOptions) (result *v1.ReplicationControllerList, err error) { - defer func() { +func (c *replicationControllers) List(ctx context.Context, opts metav1.ListOptions) (*v1.ReplicationControllerList, error) { + if watchListOptions, hasWatchListOptionsPrepared, watchListOptionsErr := watchlist.PrepareWatchListOptionsFromListOptions(opts); watchListOptionsErr != nil { + klog.Warningf("Failed preparing watchlist options for replicationcontrollers, falling back to the standard LIST semantics, err = %v", watchListOptionsErr) + } else if hasWatchListOptionsPrepared { + result, err := c.watchList(ctx, watchListOptions) if err == nil { - consistencydetector.CheckListFromCacheDataConsistencyIfRequested(ctx, "list request for replicationcontrollers", c.list, opts, result) + consistencydetector.CheckWatchListFromCacheDataConsistencyIfRequested(ctx, "watchlist request for replicationcontrollers", c.list, opts, result) + return result, nil } - }() - return c.list(ctx, opts) + klog.Warningf("The watchlist request for replicationcontrollers ended with an error, falling back to the standard LIST semantics, err = %v", err) + } + result, err := c.list(ctx, opts) + if err == nil { + consistencydetector.CheckListFromCacheDataConsistencyIfRequested(ctx, "list request for replicationcontrollers", c.list, opts, result) + } + return result, err } // list takes label and field selectors, and returns the list of ReplicationControllers that match those selectors. @@ -114,6 +125,23 @@ func (c *replicationControllers) list(ctx context.Context, opts metav1.ListOptio return } +// watchList establishes a watch stream with the server and returns the list of ReplicationControllers +func (c *replicationControllers) watchList(ctx context.Context, opts metav1.ListOptions) (result *v1.ReplicationControllerList, err error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + result = &v1.ReplicationControllerList{} + err = c.client.Get(). + Namespace(c.ns). + Resource("replicationcontrollers"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + WatchList(ctx). + Into(result) + return +} + // Watch returns a watch.Interface that watches the requested replicationControllers. func (c *replicationControllers) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { var timeout time.Duration diff --git a/staging/src/k8s.io/client-go/kubernetes/typed/core/v1/resourcequota.go b/staging/src/k8s.io/client-go/kubernetes/typed/core/v1/resourcequota.go index 32d0e33ebdc..3e28a0b0554 100644 --- a/staging/src/k8s.io/client-go/kubernetes/typed/core/v1/resourcequota.go +++ b/staging/src/k8s.io/client-go/kubernetes/typed/core/v1/resourcequota.go @@ -32,6 +32,8 @@ import ( scheme "k8s.io/client-go/kubernetes/scheme" rest "k8s.io/client-go/rest" consistencydetector "k8s.io/client-go/util/consistencydetector" + watchlist "k8s.io/client-go/util/watchlist" + "k8s.io/klog/v2" ) // ResourceQuotasGetter has a method to return a ResourceQuotaInterface. @@ -84,13 +86,22 @@ func (c *resourceQuotas) Get(ctx context.Context, name string, options metav1.Ge } // List takes label and field selectors, and returns the list of ResourceQuotas that match those selectors. -func (c *resourceQuotas) List(ctx context.Context, opts metav1.ListOptions) (result *v1.ResourceQuotaList, err error) { - defer func() { +func (c *resourceQuotas) List(ctx context.Context, opts metav1.ListOptions) (*v1.ResourceQuotaList, error) { + if watchListOptions, hasWatchListOptionsPrepared, watchListOptionsErr := watchlist.PrepareWatchListOptionsFromListOptions(opts); watchListOptionsErr != nil { + klog.Warningf("Failed preparing watchlist options for resourcequotas, falling back to the standard LIST semantics, err = %v", watchListOptionsErr) + } else if hasWatchListOptionsPrepared { + result, err := c.watchList(ctx, watchListOptions) if err == nil { - consistencydetector.CheckListFromCacheDataConsistencyIfRequested(ctx, "list request for resourcequotas", c.list, opts, result) + consistencydetector.CheckWatchListFromCacheDataConsistencyIfRequested(ctx, "watchlist request for resourcequotas", c.list, opts, result) + return result, nil } - }() - return c.list(ctx, opts) + klog.Warningf("The watchlist request for resourcequotas ended with an error, falling back to the standard LIST semantics, err = %v", err) + } + result, err := c.list(ctx, opts) + if err == nil { + consistencydetector.CheckListFromCacheDataConsistencyIfRequested(ctx, "list request for resourcequotas", c.list, opts, result) + } + return result, err } // list takes label and field selectors, and returns the list of ResourceQuotas that match those selectors. @@ -110,6 +121,23 @@ func (c *resourceQuotas) list(ctx context.Context, opts metav1.ListOptions) (res return } +// watchList establishes a watch stream with the server and returns the list of ResourceQuotas +func (c *resourceQuotas) watchList(ctx context.Context, opts metav1.ListOptions) (result *v1.ResourceQuotaList, err error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + result = &v1.ResourceQuotaList{} + err = c.client.Get(). + Namespace(c.ns). + Resource("resourcequotas"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + WatchList(ctx). + Into(result) + return +} + // Watch returns a watch.Interface that watches the requested resourceQuotas. func (c *resourceQuotas) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { var timeout time.Duration diff --git a/staging/src/k8s.io/client-go/kubernetes/typed/core/v1/secret.go b/staging/src/k8s.io/client-go/kubernetes/typed/core/v1/secret.go index d0eee669180..61998f848a2 100644 --- a/staging/src/k8s.io/client-go/kubernetes/typed/core/v1/secret.go +++ b/staging/src/k8s.io/client-go/kubernetes/typed/core/v1/secret.go @@ -32,6 +32,8 @@ import ( scheme "k8s.io/client-go/kubernetes/scheme" rest "k8s.io/client-go/rest" consistencydetector "k8s.io/client-go/util/consistencydetector" + watchlist "k8s.io/client-go/util/watchlist" + "k8s.io/klog/v2" ) // SecretsGetter has a method to return a SecretInterface. @@ -82,13 +84,22 @@ func (c *secrets) Get(ctx context.Context, name string, options metav1.GetOption } // List takes label and field selectors, and returns the list of Secrets that match those selectors. -func (c *secrets) List(ctx context.Context, opts metav1.ListOptions) (result *v1.SecretList, err error) { - defer func() { +func (c *secrets) List(ctx context.Context, opts metav1.ListOptions) (*v1.SecretList, error) { + if watchListOptions, hasWatchListOptionsPrepared, watchListOptionsErr := watchlist.PrepareWatchListOptionsFromListOptions(opts); watchListOptionsErr != nil { + klog.Warningf("Failed preparing watchlist options for secrets, falling back to the standard LIST semantics, err = %v", watchListOptionsErr) + } else if hasWatchListOptionsPrepared { + result, err := c.watchList(ctx, watchListOptions) if err == nil { - consistencydetector.CheckListFromCacheDataConsistencyIfRequested(ctx, "list request for secrets", c.list, opts, result) + consistencydetector.CheckWatchListFromCacheDataConsistencyIfRequested(ctx, "watchlist request for secrets", c.list, opts, result) + return result, nil } - }() - return c.list(ctx, opts) + klog.Warningf("The watchlist request for secrets ended with an error, falling back to the standard LIST semantics, err = %v", err) + } + result, err := c.list(ctx, opts) + if err == nil { + consistencydetector.CheckListFromCacheDataConsistencyIfRequested(ctx, "list request for secrets", c.list, opts, result) + } + return result, err } // list takes label and field selectors, and returns the list of Secrets that match those selectors. @@ -108,6 +119,23 @@ func (c *secrets) list(ctx context.Context, opts metav1.ListOptions) (result *v1 return } +// watchList establishes a watch stream with the server and returns the list of Secrets +func (c *secrets) watchList(ctx context.Context, opts metav1.ListOptions) (result *v1.SecretList, err error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + result = &v1.SecretList{} + err = c.client.Get(). + Namespace(c.ns). + Resource("secrets"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + WatchList(ctx). + Into(result) + return +} + // Watch returns a watch.Interface that watches the requested secrets. func (c *secrets) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { var timeout time.Duration diff --git a/staging/src/k8s.io/client-go/kubernetes/typed/core/v1/service.go b/staging/src/k8s.io/client-go/kubernetes/typed/core/v1/service.go index b87f5acdc91..07c6a59da11 100644 --- a/staging/src/k8s.io/client-go/kubernetes/typed/core/v1/service.go +++ b/staging/src/k8s.io/client-go/kubernetes/typed/core/v1/service.go @@ -32,6 +32,8 @@ import ( scheme "k8s.io/client-go/kubernetes/scheme" rest "k8s.io/client-go/rest" consistencydetector "k8s.io/client-go/util/consistencydetector" + watchlist "k8s.io/client-go/util/watchlist" + "k8s.io/klog/v2" ) // ServicesGetter has a method to return a ServiceInterface. @@ -83,13 +85,22 @@ func (c *services) Get(ctx context.Context, name string, options metav1.GetOptio } // List takes label and field selectors, and returns the list of Services that match those selectors. -func (c *services) List(ctx context.Context, opts metav1.ListOptions) (result *v1.ServiceList, err error) { - defer func() { +func (c *services) List(ctx context.Context, opts metav1.ListOptions) (*v1.ServiceList, error) { + if watchListOptions, hasWatchListOptionsPrepared, watchListOptionsErr := watchlist.PrepareWatchListOptionsFromListOptions(opts); watchListOptionsErr != nil { + klog.Warningf("Failed preparing watchlist options for services, falling back to the standard LIST semantics, err = %v", watchListOptionsErr) + } else if hasWatchListOptionsPrepared { + result, err := c.watchList(ctx, watchListOptions) if err == nil { - consistencydetector.CheckListFromCacheDataConsistencyIfRequested(ctx, "list request for services", c.list, opts, result) + consistencydetector.CheckWatchListFromCacheDataConsistencyIfRequested(ctx, "watchlist request for services", c.list, opts, result) + return result, nil } - }() - return c.list(ctx, opts) + klog.Warningf("The watchlist request for services ended with an error, falling back to the standard LIST semantics, err = %v", err) + } + result, err := c.list(ctx, opts) + if err == nil { + consistencydetector.CheckListFromCacheDataConsistencyIfRequested(ctx, "list request for services", c.list, opts, result) + } + return result, err } // list takes label and field selectors, and returns the list of Services that match those selectors. @@ -109,6 +120,23 @@ func (c *services) list(ctx context.Context, opts metav1.ListOptions) (result *v return } +// watchList establishes a watch stream with the server and returns the list of Services +func (c *services) watchList(ctx context.Context, opts metav1.ListOptions) (result *v1.ServiceList, err error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + result = &v1.ServiceList{} + err = c.client.Get(). + Namespace(c.ns). + Resource("services"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + WatchList(ctx). + Into(result) + return +} + // Watch returns a watch.Interface that watches the requested services. func (c *services) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { var timeout time.Duration diff --git a/staging/src/k8s.io/client-go/kubernetes/typed/core/v1/serviceaccount.go b/staging/src/k8s.io/client-go/kubernetes/typed/core/v1/serviceaccount.go index ea08445ec43..956059161be 100644 --- a/staging/src/k8s.io/client-go/kubernetes/typed/core/v1/serviceaccount.go +++ b/staging/src/k8s.io/client-go/kubernetes/typed/core/v1/serviceaccount.go @@ -33,6 +33,8 @@ import ( scheme "k8s.io/client-go/kubernetes/scheme" rest "k8s.io/client-go/rest" consistencydetector "k8s.io/client-go/util/consistencydetector" + watchlist "k8s.io/client-go/util/watchlist" + "k8s.io/klog/v2" ) // ServiceAccountsGetter has a method to return a ServiceAccountInterface. @@ -85,13 +87,22 @@ func (c *serviceAccounts) Get(ctx context.Context, name string, options metav1.G } // List takes label and field selectors, and returns the list of ServiceAccounts that match those selectors. -func (c *serviceAccounts) List(ctx context.Context, opts metav1.ListOptions) (result *v1.ServiceAccountList, err error) { - defer func() { +func (c *serviceAccounts) List(ctx context.Context, opts metav1.ListOptions) (*v1.ServiceAccountList, error) { + if watchListOptions, hasWatchListOptionsPrepared, watchListOptionsErr := watchlist.PrepareWatchListOptionsFromListOptions(opts); watchListOptionsErr != nil { + klog.Warningf("Failed preparing watchlist options for serviceaccounts, falling back to the standard LIST semantics, err = %v", watchListOptionsErr) + } else if hasWatchListOptionsPrepared { + result, err := c.watchList(ctx, watchListOptions) if err == nil { - consistencydetector.CheckListFromCacheDataConsistencyIfRequested(ctx, "list request for serviceaccounts", c.list, opts, result) + consistencydetector.CheckWatchListFromCacheDataConsistencyIfRequested(ctx, "watchlist request for serviceaccounts", c.list, opts, result) + return result, nil } - }() - return c.list(ctx, opts) + klog.Warningf("The watchlist request for serviceaccounts ended with an error, falling back to the standard LIST semantics, err = %v", err) + } + result, err := c.list(ctx, opts) + if err == nil { + consistencydetector.CheckListFromCacheDataConsistencyIfRequested(ctx, "list request for serviceaccounts", c.list, opts, result) + } + return result, err } // list takes label and field selectors, and returns the list of ServiceAccounts that match those selectors. @@ -111,6 +122,23 @@ func (c *serviceAccounts) list(ctx context.Context, opts metav1.ListOptions) (re return } +// watchList establishes a watch stream with the server and returns the list of ServiceAccounts +func (c *serviceAccounts) watchList(ctx context.Context, opts metav1.ListOptions) (result *v1.ServiceAccountList, err error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + result = &v1.ServiceAccountList{} + err = c.client.Get(). + Namespace(c.ns). + Resource("serviceaccounts"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + WatchList(ctx). + Into(result) + return +} + // Watch returns a watch.Interface that watches the requested serviceAccounts. func (c *serviceAccounts) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { var timeout time.Duration diff --git a/staging/src/k8s.io/client-go/kubernetes/typed/discovery/v1/endpointslice.go b/staging/src/k8s.io/client-go/kubernetes/typed/discovery/v1/endpointslice.go index eb9503bddc6..1a364e384a3 100644 --- a/staging/src/k8s.io/client-go/kubernetes/typed/discovery/v1/endpointslice.go +++ b/staging/src/k8s.io/client-go/kubernetes/typed/discovery/v1/endpointslice.go @@ -32,6 +32,8 @@ import ( scheme "k8s.io/client-go/kubernetes/scheme" rest "k8s.io/client-go/rest" consistencydetector "k8s.io/client-go/util/consistencydetector" + watchlist "k8s.io/client-go/util/watchlist" + "k8s.io/klog/v2" ) // EndpointSlicesGetter has a method to return a EndpointSliceInterface. @@ -82,13 +84,22 @@ func (c *endpointSlices) Get(ctx context.Context, name string, options metav1.Ge } // List takes label and field selectors, and returns the list of EndpointSlices that match those selectors. -func (c *endpointSlices) List(ctx context.Context, opts metav1.ListOptions) (result *v1.EndpointSliceList, err error) { - defer func() { +func (c *endpointSlices) List(ctx context.Context, opts metav1.ListOptions) (*v1.EndpointSliceList, error) { + if watchListOptions, hasWatchListOptionsPrepared, watchListOptionsErr := watchlist.PrepareWatchListOptionsFromListOptions(opts); watchListOptionsErr != nil { + klog.Warningf("Failed preparing watchlist options for endpointslices, falling back to the standard LIST semantics, err = %v", watchListOptionsErr) + } else if hasWatchListOptionsPrepared { + result, err := c.watchList(ctx, watchListOptions) if err == nil { - consistencydetector.CheckListFromCacheDataConsistencyIfRequested(ctx, "list request for endpointslices", c.list, opts, result) + consistencydetector.CheckWatchListFromCacheDataConsistencyIfRequested(ctx, "watchlist request for endpointslices", c.list, opts, result) + return result, nil } - }() - return c.list(ctx, opts) + klog.Warningf("The watchlist request for endpointslices ended with an error, falling back to the standard LIST semantics, err = %v", err) + } + result, err := c.list(ctx, opts) + if err == nil { + consistencydetector.CheckListFromCacheDataConsistencyIfRequested(ctx, "list request for endpointslices", c.list, opts, result) + } + return result, err } // list takes label and field selectors, and returns the list of EndpointSlices that match those selectors. @@ -108,6 +119,23 @@ func (c *endpointSlices) list(ctx context.Context, opts metav1.ListOptions) (res return } +// watchList establishes a watch stream with the server and returns the list of EndpointSlices +func (c *endpointSlices) watchList(ctx context.Context, opts metav1.ListOptions) (result *v1.EndpointSliceList, err error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + result = &v1.EndpointSliceList{} + err = c.client.Get(). + Namespace(c.ns). + Resource("endpointslices"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + WatchList(ctx). + Into(result) + return +} + // Watch returns a watch.Interface that watches the requested endpointSlices. func (c *endpointSlices) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { var timeout time.Duration diff --git a/staging/src/k8s.io/client-go/kubernetes/typed/discovery/v1beta1/endpointslice.go b/staging/src/k8s.io/client-go/kubernetes/typed/discovery/v1beta1/endpointslice.go index 97f9bbb1e84..00966f8501e 100644 --- a/staging/src/k8s.io/client-go/kubernetes/typed/discovery/v1beta1/endpointslice.go +++ b/staging/src/k8s.io/client-go/kubernetes/typed/discovery/v1beta1/endpointslice.go @@ -32,6 +32,8 @@ import ( scheme "k8s.io/client-go/kubernetes/scheme" rest "k8s.io/client-go/rest" consistencydetector "k8s.io/client-go/util/consistencydetector" + watchlist "k8s.io/client-go/util/watchlist" + "k8s.io/klog/v2" ) // EndpointSlicesGetter has a method to return a EndpointSliceInterface. @@ -82,13 +84,22 @@ func (c *endpointSlices) Get(ctx context.Context, name string, options v1.GetOpt } // List takes label and field selectors, and returns the list of EndpointSlices that match those selectors. -func (c *endpointSlices) List(ctx context.Context, opts v1.ListOptions) (result *v1beta1.EndpointSliceList, err error) { - defer func() { +func (c *endpointSlices) List(ctx context.Context, opts v1.ListOptions) (*v1beta1.EndpointSliceList, error) { + if watchListOptions, hasWatchListOptionsPrepared, watchListOptionsErr := watchlist.PrepareWatchListOptionsFromListOptions(opts); watchListOptionsErr != nil { + klog.Warningf("Failed preparing watchlist options for endpointslices, falling back to the standard LIST semantics, err = %v", watchListOptionsErr) + } else if hasWatchListOptionsPrepared { + result, err := c.watchList(ctx, watchListOptions) if err == nil { - consistencydetector.CheckListFromCacheDataConsistencyIfRequested(ctx, "list request for endpointslices", c.list, opts, result) + consistencydetector.CheckWatchListFromCacheDataConsistencyIfRequested(ctx, "watchlist request for endpointslices", c.list, opts, result) + return result, nil } - }() - return c.list(ctx, opts) + klog.Warningf("The watchlist request for endpointslices ended with an error, falling back to the standard LIST semantics, err = %v", err) + } + result, err := c.list(ctx, opts) + if err == nil { + consistencydetector.CheckListFromCacheDataConsistencyIfRequested(ctx, "list request for endpointslices", c.list, opts, result) + } + return result, err } // list takes label and field selectors, and returns the list of EndpointSlices that match those selectors. @@ -108,6 +119,23 @@ func (c *endpointSlices) list(ctx context.Context, opts v1.ListOptions) (result return } +// watchList establishes a watch stream with the server and returns the list of EndpointSlices +func (c *endpointSlices) watchList(ctx context.Context, opts v1.ListOptions) (result *v1beta1.EndpointSliceList, err error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + result = &v1beta1.EndpointSliceList{} + err = c.client.Get(). + Namespace(c.ns). + Resource("endpointslices"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + WatchList(ctx). + Into(result) + return +} + // Watch returns a watch.Interface that watches the requested endpointSlices. func (c *endpointSlices) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { var timeout time.Duration diff --git a/staging/src/k8s.io/client-go/kubernetes/typed/events/v1/event.go b/staging/src/k8s.io/client-go/kubernetes/typed/events/v1/event.go index b34940c804e..129ec9a80b2 100644 --- a/staging/src/k8s.io/client-go/kubernetes/typed/events/v1/event.go +++ b/staging/src/k8s.io/client-go/kubernetes/typed/events/v1/event.go @@ -32,6 +32,8 @@ import ( scheme "k8s.io/client-go/kubernetes/scheme" rest "k8s.io/client-go/rest" consistencydetector "k8s.io/client-go/util/consistencydetector" + watchlist "k8s.io/client-go/util/watchlist" + "k8s.io/klog/v2" ) // EventsGetter has a method to return a EventInterface. @@ -82,13 +84,22 @@ func (c *events) Get(ctx context.Context, name string, options metav1.GetOptions } // List takes label and field selectors, and returns the list of Events that match those selectors. -func (c *events) List(ctx context.Context, opts metav1.ListOptions) (result *v1.EventList, err error) { - defer func() { +func (c *events) List(ctx context.Context, opts metav1.ListOptions) (*v1.EventList, error) { + if watchListOptions, hasWatchListOptionsPrepared, watchListOptionsErr := watchlist.PrepareWatchListOptionsFromListOptions(opts); watchListOptionsErr != nil { + klog.Warningf("Failed preparing watchlist options for events, falling back to the standard LIST semantics, err = %v", watchListOptionsErr) + } else if hasWatchListOptionsPrepared { + result, err := c.watchList(ctx, watchListOptions) if err == nil { - consistencydetector.CheckListFromCacheDataConsistencyIfRequested(ctx, "list request for events", c.list, opts, result) + consistencydetector.CheckWatchListFromCacheDataConsistencyIfRequested(ctx, "watchlist request for events", c.list, opts, result) + return result, nil } - }() - return c.list(ctx, opts) + klog.Warningf("The watchlist request for events ended with an error, falling back to the standard LIST semantics, err = %v", err) + } + result, err := c.list(ctx, opts) + if err == nil { + consistencydetector.CheckListFromCacheDataConsistencyIfRequested(ctx, "list request for events", c.list, opts, result) + } + return result, err } // list takes label and field selectors, and returns the list of Events that match those selectors. @@ -108,6 +119,23 @@ func (c *events) list(ctx context.Context, opts metav1.ListOptions) (result *v1. return } +// watchList establishes a watch stream with the server and returns the list of Events +func (c *events) watchList(ctx context.Context, opts metav1.ListOptions) (result *v1.EventList, err error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + result = &v1.EventList{} + err = c.client.Get(). + Namespace(c.ns). + Resource("events"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + WatchList(ctx). + Into(result) + return +} + // Watch returns a watch.Interface that watches the requested events. func (c *events) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { var timeout time.Duration diff --git a/staging/src/k8s.io/client-go/kubernetes/typed/events/v1beta1/event.go b/staging/src/k8s.io/client-go/kubernetes/typed/events/v1beta1/event.go index cc7174aa5dc..edd3ea22338 100644 --- a/staging/src/k8s.io/client-go/kubernetes/typed/events/v1beta1/event.go +++ b/staging/src/k8s.io/client-go/kubernetes/typed/events/v1beta1/event.go @@ -32,6 +32,8 @@ import ( scheme "k8s.io/client-go/kubernetes/scheme" rest "k8s.io/client-go/rest" consistencydetector "k8s.io/client-go/util/consistencydetector" + watchlist "k8s.io/client-go/util/watchlist" + "k8s.io/klog/v2" ) // EventsGetter has a method to return a EventInterface. @@ -82,13 +84,22 @@ func (c *events) Get(ctx context.Context, name string, options v1.GetOptions) (r } // List takes label and field selectors, and returns the list of Events that match those selectors. -func (c *events) List(ctx context.Context, opts v1.ListOptions) (result *v1beta1.EventList, err error) { - defer func() { +func (c *events) List(ctx context.Context, opts v1.ListOptions) (*v1beta1.EventList, error) { + if watchListOptions, hasWatchListOptionsPrepared, watchListOptionsErr := watchlist.PrepareWatchListOptionsFromListOptions(opts); watchListOptionsErr != nil { + klog.Warningf("Failed preparing watchlist options for events, falling back to the standard LIST semantics, err = %v", watchListOptionsErr) + } else if hasWatchListOptionsPrepared { + result, err := c.watchList(ctx, watchListOptions) if err == nil { - consistencydetector.CheckListFromCacheDataConsistencyIfRequested(ctx, "list request for events", c.list, opts, result) + consistencydetector.CheckWatchListFromCacheDataConsistencyIfRequested(ctx, "watchlist request for events", c.list, opts, result) + return result, nil } - }() - return c.list(ctx, opts) + klog.Warningf("The watchlist request for events ended with an error, falling back to the standard LIST semantics, err = %v", err) + } + result, err := c.list(ctx, opts) + if err == nil { + consistencydetector.CheckListFromCacheDataConsistencyIfRequested(ctx, "list request for events", c.list, opts, result) + } + return result, err } // list takes label and field selectors, and returns the list of Events that match those selectors. @@ -108,6 +119,23 @@ func (c *events) list(ctx context.Context, opts v1.ListOptions) (result *v1beta1 return } +// watchList establishes a watch stream with the server and returns the list of Events +func (c *events) watchList(ctx context.Context, opts v1.ListOptions) (result *v1beta1.EventList, err error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + result = &v1beta1.EventList{} + err = c.client.Get(). + Namespace(c.ns). + Resource("events"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + WatchList(ctx). + Into(result) + return +} + // Watch returns a watch.Interface that watches the requested events. func (c *events) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { var timeout time.Duration diff --git a/staging/src/k8s.io/client-go/kubernetes/typed/extensions/v1beta1/daemonset.go b/staging/src/k8s.io/client-go/kubernetes/typed/extensions/v1beta1/daemonset.go index 128d585e3e9..fc8ceaab4bd 100644 --- a/staging/src/k8s.io/client-go/kubernetes/typed/extensions/v1beta1/daemonset.go +++ b/staging/src/k8s.io/client-go/kubernetes/typed/extensions/v1beta1/daemonset.go @@ -32,6 +32,8 @@ import ( scheme "k8s.io/client-go/kubernetes/scheme" rest "k8s.io/client-go/rest" consistencydetector "k8s.io/client-go/util/consistencydetector" + watchlist "k8s.io/client-go/util/watchlist" + "k8s.io/klog/v2" ) // DaemonSetsGetter has a method to return a DaemonSetInterface. @@ -84,13 +86,22 @@ func (c *daemonSets) Get(ctx context.Context, name string, options v1.GetOptions } // List takes label and field selectors, and returns the list of DaemonSets that match those selectors. -func (c *daemonSets) List(ctx context.Context, opts v1.ListOptions) (result *v1beta1.DaemonSetList, err error) { - defer func() { +func (c *daemonSets) List(ctx context.Context, opts v1.ListOptions) (*v1beta1.DaemonSetList, error) { + if watchListOptions, hasWatchListOptionsPrepared, watchListOptionsErr := watchlist.PrepareWatchListOptionsFromListOptions(opts); watchListOptionsErr != nil { + klog.Warningf("Failed preparing watchlist options for daemonsets, falling back to the standard LIST semantics, err = %v", watchListOptionsErr) + } else if hasWatchListOptionsPrepared { + result, err := c.watchList(ctx, watchListOptions) if err == nil { - consistencydetector.CheckListFromCacheDataConsistencyIfRequested(ctx, "list request for daemonsets", c.list, opts, result) + consistencydetector.CheckWatchListFromCacheDataConsistencyIfRequested(ctx, "watchlist request for daemonsets", c.list, opts, result) + return result, nil } - }() - return c.list(ctx, opts) + klog.Warningf("The watchlist request for daemonsets ended with an error, falling back to the standard LIST semantics, err = %v", err) + } + result, err := c.list(ctx, opts) + if err == nil { + consistencydetector.CheckListFromCacheDataConsistencyIfRequested(ctx, "list request for daemonsets", c.list, opts, result) + } + return result, err } // list takes label and field selectors, and returns the list of DaemonSets that match those selectors. @@ -110,6 +121,23 @@ func (c *daemonSets) list(ctx context.Context, opts v1.ListOptions) (result *v1b return } +// watchList establishes a watch stream with the server and returns the list of DaemonSets +func (c *daemonSets) watchList(ctx context.Context, opts v1.ListOptions) (result *v1beta1.DaemonSetList, err error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + result = &v1beta1.DaemonSetList{} + err = c.client.Get(). + Namespace(c.ns). + Resource("daemonsets"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + WatchList(ctx). + Into(result) + return +} + // Watch returns a watch.Interface that watches the requested daemonSets. func (c *daemonSets) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { var timeout time.Duration diff --git a/staging/src/k8s.io/client-go/kubernetes/typed/extensions/v1beta1/deployment.go b/staging/src/k8s.io/client-go/kubernetes/typed/extensions/v1beta1/deployment.go index 245e05ad93c..794124b371c 100644 --- a/staging/src/k8s.io/client-go/kubernetes/typed/extensions/v1beta1/deployment.go +++ b/staging/src/k8s.io/client-go/kubernetes/typed/extensions/v1beta1/deployment.go @@ -32,6 +32,8 @@ import ( scheme "k8s.io/client-go/kubernetes/scheme" rest "k8s.io/client-go/rest" consistencydetector "k8s.io/client-go/util/consistencydetector" + watchlist "k8s.io/client-go/util/watchlist" + "k8s.io/klog/v2" ) // DeploymentsGetter has a method to return a DeploymentInterface. @@ -88,13 +90,22 @@ func (c *deployments) Get(ctx context.Context, name string, options v1.GetOption } // List takes label and field selectors, and returns the list of Deployments that match those selectors. -func (c *deployments) List(ctx context.Context, opts v1.ListOptions) (result *v1beta1.DeploymentList, err error) { - defer func() { +func (c *deployments) List(ctx context.Context, opts v1.ListOptions) (*v1beta1.DeploymentList, error) { + if watchListOptions, hasWatchListOptionsPrepared, watchListOptionsErr := watchlist.PrepareWatchListOptionsFromListOptions(opts); watchListOptionsErr != nil { + klog.Warningf("Failed preparing watchlist options for deployments, falling back to the standard LIST semantics, err = %v", watchListOptionsErr) + } else if hasWatchListOptionsPrepared { + result, err := c.watchList(ctx, watchListOptions) if err == nil { - consistencydetector.CheckListFromCacheDataConsistencyIfRequested(ctx, "list request for deployments", c.list, opts, result) + consistencydetector.CheckWatchListFromCacheDataConsistencyIfRequested(ctx, "watchlist request for deployments", c.list, opts, result) + return result, nil } - }() - return c.list(ctx, opts) + klog.Warningf("The watchlist request for deployments ended with an error, falling back to the standard LIST semantics, err = %v", err) + } + result, err := c.list(ctx, opts) + if err == nil { + consistencydetector.CheckListFromCacheDataConsistencyIfRequested(ctx, "list request for deployments", c.list, opts, result) + } + return result, err } // list takes label and field selectors, and returns the list of Deployments that match those selectors. @@ -114,6 +125,23 @@ func (c *deployments) list(ctx context.Context, opts v1.ListOptions) (result *v1 return } +// watchList establishes a watch stream with the server and returns the list of Deployments +func (c *deployments) watchList(ctx context.Context, opts v1.ListOptions) (result *v1beta1.DeploymentList, err error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + result = &v1beta1.DeploymentList{} + err = c.client.Get(). + Namespace(c.ns). + Resource("deployments"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + WatchList(ctx). + Into(result) + return +} + // Watch returns a watch.Interface that watches the requested deployments. func (c *deployments) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { var timeout time.Duration diff --git a/staging/src/k8s.io/client-go/kubernetes/typed/extensions/v1beta1/ingress.go b/staging/src/k8s.io/client-go/kubernetes/typed/extensions/v1beta1/ingress.go index c5c0376c32c..dcb8f369f27 100644 --- a/staging/src/k8s.io/client-go/kubernetes/typed/extensions/v1beta1/ingress.go +++ b/staging/src/k8s.io/client-go/kubernetes/typed/extensions/v1beta1/ingress.go @@ -32,6 +32,8 @@ import ( scheme "k8s.io/client-go/kubernetes/scheme" rest "k8s.io/client-go/rest" consistencydetector "k8s.io/client-go/util/consistencydetector" + watchlist "k8s.io/client-go/util/watchlist" + "k8s.io/klog/v2" ) // IngressesGetter has a method to return a IngressInterface. @@ -84,13 +86,22 @@ func (c *ingresses) Get(ctx context.Context, name string, options v1.GetOptions) } // List takes label and field selectors, and returns the list of Ingresses that match those selectors. -func (c *ingresses) List(ctx context.Context, opts v1.ListOptions) (result *v1beta1.IngressList, err error) { - defer func() { +func (c *ingresses) List(ctx context.Context, opts v1.ListOptions) (*v1beta1.IngressList, error) { + if watchListOptions, hasWatchListOptionsPrepared, watchListOptionsErr := watchlist.PrepareWatchListOptionsFromListOptions(opts); watchListOptionsErr != nil { + klog.Warningf("Failed preparing watchlist options for ingresses, falling back to the standard LIST semantics, err = %v", watchListOptionsErr) + } else if hasWatchListOptionsPrepared { + result, err := c.watchList(ctx, watchListOptions) if err == nil { - consistencydetector.CheckListFromCacheDataConsistencyIfRequested(ctx, "list request for ingresses", c.list, opts, result) + consistencydetector.CheckWatchListFromCacheDataConsistencyIfRequested(ctx, "watchlist request for ingresses", c.list, opts, result) + return result, nil } - }() - return c.list(ctx, opts) + klog.Warningf("The watchlist request for ingresses ended with an error, falling back to the standard LIST semantics, err = %v", err) + } + result, err := c.list(ctx, opts) + if err == nil { + consistencydetector.CheckListFromCacheDataConsistencyIfRequested(ctx, "list request for ingresses", c.list, opts, result) + } + return result, err } // list takes label and field selectors, and returns the list of Ingresses that match those selectors. @@ -110,6 +121,23 @@ func (c *ingresses) list(ctx context.Context, opts v1.ListOptions) (result *v1be return } +// watchList establishes a watch stream with the server and returns the list of Ingresses +func (c *ingresses) watchList(ctx context.Context, opts v1.ListOptions) (result *v1beta1.IngressList, err error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + result = &v1beta1.IngressList{} + err = c.client.Get(). + Namespace(c.ns). + Resource("ingresses"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + WatchList(ctx). + Into(result) + return +} + // Watch returns a watch.Interface that watches the requested ingresses. func (c *ingresses) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { var timeout time.Duration diff --git a/staging/src/k8s.io/client-go/kubernetes/typed/extensions/v1beta1/networkpolicy.go b/staging/src/k8s.io/client-go/kubernetes/typed/extensions/v1beta1/networkpolicy.go index 9bbe4257966..7140ff5fcf6 100644 --- a/staging/src/k8s.io/client-go/kubernetes/typed/extensions/v1beta1/networkpolicy.go +++ b/staging/src/k8s.io/client-go/kubernetes/typed/extensions/v1beta1/networkpolicy.go @@ -32,6 +32,8 @@ import ( scheme "k8s.io/client-go/kubernetes/scheme" rest "k8s.io/client-go/rest" consistencydetector "k8s.io/client-go/util/consistencydetector" + watchlist "k8s.io/client-go/util/watchlist" + "k8s.io/klog/v2" ) // NetworkPoliciesGetter has a method to return a NetworkPolicyInterface. @@ -82,13 +84,22 @@ func (c *networkPolicies) Get(ctx context.Context, name string, options v1.GetOp } // List takes label and field selectors, and returns the list of NetworkPolicies that match those selectors. -func (c *networkPolicies) List(ctx context.Context, opts v1.ListOptions) (result *v1beta1.NetworkPolicyList, err error) { - defer func() { +func (c *networkPolicies) List(ctx context.Context, opts v1.ListOptions) (*v1beta1.NetworkPolicyList, error) { + if watchListOptions, hasWatchListOptionsPrepared, watchListOptionsErr := watchlist.PrepareWatchListOptionsFromListOptions(opts); watchListOptionsErr != nil { + klog.Warningf("Failed preparing watchlist options for networkpolicies, falling back to the standard LIST semantics, err = %v", watchListOptionsErr) + } else if hasWatchListOptionsPrepared { + result, err := c.watchList(ctx, watchListOptions) if err == nil { - consistencydetector.CheckListFromCacheDataConsistencyIfRequested(ctx, "list request for networkpolicies", c.list, opts, result) + consistencydetector.CheckWatchListFromCacheDataConsistencyIfRequested(ctx, "watchlist request for networkpolicies", c.list, opts, result) + return result, nil } - }() - return c.list(ctx, opts) + klog.Warningf("The watchlist request for networkpolicies ended with an error, falling back to the standard LIST semantics, err = %v", err) + } + result, err := c.list(ctx, opts) + if err == nil { + consistencydetector.CheckListFromCacheDataConsistencyIfRequested(ctx, "list request for networkpolicies", c.list, opts, result) + } + return result, err } // list takes label and field selectors, and returns the list of NetworkPolicies that match those selectors. @@ -108,6 +119,23 @@ func (c *networkPolicies) list(ctx context.Context, opts v1.ListOptions) (result return } +// watchList establishes a watch stream with the server and returns the list of NetworkPolicies +func (c *networkPolicies) watchList(ctx context.Context, opts v1.ListOptions) (result *v1beta1.NetworkPolicyList, err error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + result = &v1beta1.NetworkPolicyList{} + err = c.client.Get(). + Namespace(c.ns). + Resource("networkpolicies"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + WatchList(ctx). + Into(result) + return +} + // Watch returns a watch.Interface that watches the requested networkPolicies. func (c *networkPolicies) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { var timeout time.Duration diff --git a/staging/src/k8s.io/client-go/kubernetes/typed/extensions/v1beta1/replicaset.go b/staging/src/k8s.io/client-go/kubernetes/typed/extensions/v1beta1/replicaset.go index 1ac971cfaec..363857e6da6 100644 --- a/staging/src/k8s.io/client-go/kubernetes/typed/extensions/v1beta1/replicaset.go +++ b/staging/src/k8s.io/client-go/kubernetes/typed/extensions/v1beta1/replicaset.go @@ -32,6 +32,8 @@ import ( scheme "k8s.io/client-go/kubernetes/scheme" rest "k8s.io/client-go/rest" consistencydetector "k8s.io/client-go/util/consistencydetector" + watchlist "k8s.io/client-go/util/watchlist" + "k8s.io/klog/v2" ) // ReplicaSetsGetter has a method to return a ReplicaSetInterface. @@ -88,13 +90,22 @@ func (c *replicaSets) Get(ctx context.Context, name string, options v1.GetOption } // List takes label and field selectors, and returns the list of ReplicaSets that match those selectors. -func (c *replicaSets) List(ctx context.Context, opts v1.ListOptions) (result *v1beta1.ReplicaSetList, err error) { - defer func() { +func (c *replicaSets) List(ctx context.Context, opts v1.ListOptions) (*v1beta1.ReplicaSetList, error) { + if watchListOptions, hasWatchListOptionsPrepared, watchListOptionsErr := watchlist.PrepareWatchListOptionsFromListOptions(opts); watchListOptionsErr != nil { + klog.Warningf("Failed preparing watchlist options for replicasets, falling back to the standard LIST semantics, err = %v", watchListOptionsErr) + } else if hasWatchListOptionsPrepared { + result, err := c.watchList(ctx, watchListOptions) if err == nil { - consistencydetector.CheckListFromCacheDataConsistencyIfRequested(ctx, "list request for replicasets", c.list, opts, result) + consistencydetector.CheckWatchListFromCacheDataConsistencyIfRequested(ctx, "watchlist request for replicasets", c.list, opts, result) + return result, nil } - }() - return c.list(ctx, opts) + klog.Warningf("The watchlist request for replicasets ended with an error, falling back to the standard LIST semantics, err = %v", err) + } + result, err := c.list(ctx, opts) + if err == nil { + consistencydetector.CheckListFromCacheDataConsistencyIfRequested(ctx, "list request for replicasets", c.list, opts, result) + } + return result, err } // list takes label and field selectors, and returns the list of ReplicaSets that match those selectors. @@ -114,6 +125,23 @@ func (c *replicaSets) list(ctx context.Context, opts v1.ListOptions) (result *v1 return } +// watchList establishes a watch stream with the server and returns the list of ReplicaSets +func (c *replicaSets) watchList(ctx context.Context, opts v1.ListOptions) (result *v1beta1.ReplicaSetList, err error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + result = &v1beta1.ReplicaSetList{} + err = c.client.Get(). + Namespace(c.ns). + Resource("replicasets"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + WatchList(ctx). + Into(result) + return +} + // Watch returns a watch.Interface that watches the requested replicaSets. func (c *replicaSets) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { var timeout time.Duration diff --git a/staging/src/k8s.io/client-go/kubernetes/typed/flowcontrol/v1/flowschema.go b/staging/src/k8s.io/client-go/kubernetes/typed/flowcontrol/v1/flowschema.go index 504338ea55d..966e12b8d40 100644 --- a/staging/src/k8s.io/client-go/kubernetes/typed/flowcontrol/v1/flowschema.go +++ b/staging/src/k8s.io/client-go/kubernetes/typed/flowcontrol/v1/flowschema.go @@ -32,6 +32,8 @@ import ( scheme "k8s.io/client-go/kubernetes/scheme" rest "k8s.io/client-go/rest" consistencydetector "k8s.io/client-go/util/consistencydetector" + watchlist "k8s.io/client-go/util/watchlist" + "k8s.io/klog/v2" ) // FlowSchemasGetter has a method to return a FlowSchemaInterface. @@ -81,13 +83,22 @@ func (c *flowSchemas) Get(ctx context.Context, name string, options metav1.GetOp } // List takes label and field selectors, and returns the list of FlowSchemas that match those selectors. -func (c *flowSchemas) List(ctx context.Context, opts metav1.ListOptions) (result *v1.FlowSchemaList, err error) { - defer func() { +func (c *flowSchemas) List(ctx context.Context, opts metav1.ListOptions) (*v1.FlowSchemaList, error) { + if watchListOptions, hasWatchListOptionsPrepared, watchListOptionsErr := watchlist.PrepareWatchListOptionsFromListOptions(opts); watchListOptionsErr != nil { + klog.Warningf("Failed preparing watchlist options for flowschemas, falling back to the standard LIST semantics, err = %v", watchListOptionsErr) + } else if hasWatchListOptionsPrepared { + result, err := c.watchList(ctx, watchListOptions) if err == nil { - consistencydetector.CheckListFromCacheDataConsistencyIfRequested(ctx, "list request for flowschemas", c.list, opts, result) + consistencydetector.CheckWatchListFromCacheDataConsistencyIfRequested(ctx, "watchlist request for flowschemas", c.list, opts, result) + return result, nil } - }() - return c.list(ctx, opts) + klog.Warningf("The watchlist request for flowschemas ended with an error, falling back to the standard LIST semantics, err = %v", err) + } + result, err := c.list(ctx, opts) + if err == nil { + consistencydetector.CheckListFromCacheDataConsistencyIfRequested(ctx, "list request for flowschemas", c.list, opts, result) + } + return result, err } // list takes label and field selectors, and returns the list of FlowSchemas that match those selectors. @@ -106,6 +117,22 @@ func (c *flowSchemas) list(ctx context.Context, opts metav1.ListOptions) (result return } +// watchList establishes a watch stream with the server and returns the list of FlowSchemas +func (c *flowSchemas) watchList(ctx context.Context, opts metav1.ListOptions) (result *v1.FlowSchemaList, err error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + result = &v1.FlowSchemaList{} + err = c.client.Get(). + Resource("flowschemas"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + WatchList(ctx). + Into(result) + return +} + // Watch returns a watch.Interface that watches the requested flowSchemas. func (c *flowSchemas) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { var timeout time.Duration diff --git a/staging/src/k8s.io/client-go/kubernetes/typed/flowcontrol/v1/prioritylevelconfiguration.go b/staging/src/k8s.io/client-go/kubernetes/typed/flowcontrol/v1/prioritylevelconfiguration.go index 15328d0dc0a..2859a5f47ac 100644 --- a/staging/src/k8s.io/client-go/kubernetes/typed/flowcontrol/v1/prioritylevelconfiguration.go +++ b/staging/src/k8s.io/client-go/kubernetes/typed/flowcontrol/v1/prioritylevelconfiguration.go @@ -32,6 +32,8 @@ import ( scheme "k8s.io/client-go/kubernetes/scheme" rest "k8s.io/client-go/rest" consistencydetector "k8s.io/client-go/util/consistencydetector" + watchlist "k8s.io/client-go/util/watchlist" + "k8s.io/klog/v2" ) // PriorityLevelConfigurationsGetter has a method to return a PriorityLevelConfigurationInterface. @@ -81,13 +83,22 @@ func (c *priorityLevelConfigurations) Get(ctx context.Context, name string, opti } // List takes label and field selectors, and returns the list of PriorityLevelConfigurations that match those selectors. -func (c *priorityLevelConfigurations) List(ctx context.Context, opts metav1.ListOptions) (result *v1.PriorityLevelConfigurationList, err error) { - defer func() { +func (c *priorityLevelConfigurations) List(ctx context.Context, opts metav1.ListOptions) (*v1.PriorityLevelConfigurationList, error) { + if watchListOptions, hasWatchListOptionsPrepared, watchListOptionsErr := watchlist.PrepareWatchListOptionsFromListOptions(opts); watchListOptionsErr != nil { + klog.Warningf("Failed preparing watchlist options for prioritylevelconfigurations, falling back to the standard LIST semantics, err = %v", watchListOptionsErr) + } else if hasWatchListOptionsPrepared { + result, err := c.watchList(ctx, watchListOptions) if err == nil { - consistencydetector.CheckListFromCacheDataConsistencyIfRequested(ctx, "list request for prioritylevelconfigurations", c.list, opts, result) + consistencydetector.CheckWatchListFromCacheDataConsistencyIfRequested(ctx, "watchlist request for prioritylevelconfigurations", c.list, opts, result) + return result, nil } - }() - return c.list(ctx, opts) + klog.Warningf("The watchlist request for prioritylevelconfigurations ended with an error, falling back to the standard LIST semantics, err = %v", err) + } + result, err := c.list(ctx, opts) + if err == nil { + consistencydetector.CheckListFromCacheDataConsistencyIfRequested(ctx, "list request for prioritylevelconfigurations", c.list, opts, result) + } + return result, err } // list takes label and field selectors, and returns the list of PriorityLevelConfigurations that match those selectors. @@ -106,6 +117,22 @@ func (c *priorityLevelConfigurations) list(ctx context.Context, opts metav1.List return } +// watchList establishes a watch stream with the server and returns the list of PriorityLevelConfigurations +func (c *priorityLevelConfigurations) watchList(ctx context.Context, opts metav1.ListOptions) (result *v1.PriorityLevelConfigurationList, err error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + result = &v1.PriorityLevelConfigurationList{} + err = c.client.Get(). + Resource("prioritylevelconfigurations"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + WatchList(ctx). + Into(result) + return +} + // Watch returns a watch.Interface that watches the requested priorityLevelConfigurations. func (c *priorityLevelConfigurations) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { var timeout time.Duration diff --git a/staging/src/k8s.io/client-go/kubernetes/typed/flowcontrol/v1beta1/flowschema.go b/staging/src/k8s.io/client-go/kubernetes/typed/flowcontrol/v1beta1/flowschema.go index b6a6ea58444..33bd0e1c2e7 100644 --- a/staging/src/k8s.io/client-go/kubernetes/typed/flowcontrol/v1beta1/flowschema.go +++ b/staging/src/k8s.io/client-go/kubernetes/typed/flowcontrol/v1beta1/flowschema.go @@ -32,6 +32,8 @@ import ( scheme "k8s.io/client-go/kubernetes/scheme" rest "k8s.io/client-go/rest" consistencydetector "k8s.io/client-go/util/consistencydetector" + watchlist "k8s.io/client-go/util/watchlist" + "k8s.io/klog/v2" ) // FlowSchemasGetter has a method to return a FlowSchemaInterface. @@ -81,13 +83,22 @@ func (c *flowSchemas) Get(ctx context.Context, name string, options v1.GetOption } // List takes label and field selectors, and returns the list of FlowSchemas that match those selectors. -func (c *flowSchemas) List(ctx context.Context, opts v1.ListOptions) (result *v1beta1.FlowSchemaList, err error) { - defer func() { +func (c *flowSchemas) List(ctx context.Context, opts v1.ListOptions) (*v1beta1.FlowSchemaList, error) { + if watchListOptions, hasWatchListOptionsPrepared, watchListOptionsErr := watchlist.PrepareWatchListOptionsFromListOptions(opts); watchListOptionsErr != nil { + klog.Warningf("Failed preparing watchlist options for flowschemas, falling back to the standard LIST semantics, err = %v", watchListOptionsErr) + } else if hasWatchListOptionsPrepared { + result, err := c.watchList(ctx, watchListOptions) if err == nil { - consistencydetector.CheckListFromCacheDataConsistencyIfRequested(ctx, "list request for flowschemas", c.list, opts, result) + consistencydetector.CheckWatchListFromCacheDataConsistencyIfRequested(ctx, "watchlist request for flowschemas", c.list, opts, result) + return result, nil } - }() - return c.list(ctx, opts) + klog.Warningf("The watchlist request for flowschemas ended with an error, falling back to the standard LIST semantics, err = %v", err) + } + result, err := c.list(ctx, opts) + if err == nil { + consistencydetector.CheckListFromCacheDataConsistencyIfRequested(ctx, "list request for flowschemas", c.list, opts, result) + } + return result, err } // list takes label and field selectors, and returns the list of FlowSchemas that match those selectors. @@ -106,6 +117,22 @@ func (c *flowSchemas) list(ctx context.Context, opts v1.ListOptions) (result *v1 return } +// watchList establishes a watch stream with the server and returns the list of FlowSchemas +func (c *flowSchemas) watchList(ctx context.Context, opts v1.ListOptions) (result *v1beta1.FlowSchemaList, err error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + result = &v1beta1.FlowSchemaList{} + err = c.client.Get(). + Resource("flowschemas"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + WatchList(ctx). + Into(result) + return +} + // Watch returns a watch.Interface that watches the requested flowSchemas. func (c *flowSchemas) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { var timeout time.Duration diff --git a/staging/src/k8s.io/client-go/kubernetes/typed/flowcontrol/v1beta1/prioritylevelconfiguration.go b/staging/src/k8s.io/client-go/kubernetes/typed/flowcontrol/v1beta1/prioritylevelconfiguration.go index 7dff545309f..42ac35353c0 100644 --- a/staging/src/k8s.io/client-go/kubernetes/typed/flowcontrol/v1beta1/prioritylevelconfiguration.go +++ b/staging/src/k8s.io/client-go/kubernetes/typed/flowcontrol/v1beta1/prioritylevelconfiguration.go @@ -32,6 +32,8 @@ import ( scheme "k8s.io/client-go/kubernetes/scheme" rest "k8s.io/client-go/rest" consistencydetector "k8s.io/client-go/util/consistencydetector" + watchlist "k8s.io/client-go/util/watchlist" + "k8s.io/klog/v2" ) // PriorityLevelConfigurationsGetter has a method to return a PriorityLevelConfigurationInterface. @@ -81,13 +83,22 @@ func (c *priorityLevelConfigurations) Get(ctx context.Context, name string, opti } // List takes label and field selectors, and returns the list of PriorityLevelConfigurations that match those selectors. -func (c *priorityLevelConfigurations) List(ctx context.Context, opts v1.ListOptions) (result *v1beta1.PriorityLevelConfigurationList, err error) { - defer func() { +func (c *priorityLevelConfigurations) List(ctx context.Context, opts v1.ListOptions) (*v1beta1.PriorityLevelConfigurationList, error) { + if watchListOptions, hasWatchListOptionsPrepared, watchListOptionsErr := watchlist.PrepareWatchListOptionsFromListOptions(opts); watchListOptionsErr != nil { + klog.Warningf("Failed preparing watchlist options for prioritylevelconfigurations, falling back to the standard LIST semantics, err = %v", watchListOptionsErr) + } else if hasWatchListOptionsPrepared { + result, err := c.watchList(ctx, watchListOptions) if err == nil { - consistencydetector.CheckListFromCacheDataConsistencyIfRequested(ctx, "list request for prioritylevelconfigurations", c.list, opts, result) + consistencydetector.CheckWatchListFromCacheDataConsistencyIfRequested(ctx, "watchlist request for prioritylevelconfigurations", c.list, opts, result) + return result, nil } - }() - return c.list(ctx, opts) + klog.Warningf("The watchlist request for prioritylevelconfigurations ended with an error, falling back to the standard LIST semantics, err = %v", err) + } + result, err := c.list(ctx, opts) + if err == nil { + consistencydetector.CheckListFromCacheDataConsistencyIfRequested(ctx, "list request for prioritylevelconfigurations", c.list, opts, result) + } + return result, err } // list takes label and field selectors, and returns the list of PriorityLevelConfigurations that match those selectors. @@ -106,6 +117,22 @@ func (c *priorityLevelConfigurations) list(ctx context.Context, opts v1.ListOpti return } +// watchList establishes a watch stream with the server and returns the list of PriorityLevelConfigurations +func (c *priorityLevelConfigurations) watchList(ctx context.Context, opts v1.ListOptions) (result *v1beta1.PriorityLevelConfigurationList, err error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + result = &v1beta1.PriorityLevelConfigurationList{} + err = c.client.Get(). + Resource("prioritylevelconfigurations"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + WatchList(ctx). + Into(result) + return +} + // Watch returns a watch.Interface that watches the requested priorityLevelConfigurations. func (c *priorityLevelConfigurations) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { var timeout time.Duration diff --git a/staging/src/k8s.io/client-go/kubernetes/typed/flowcontrol/v1beta2/flowschema.go b/staging/src/k8s.io/client-go/kubernetes/typed/flowcontrol/v1beta2/flowschema.go index 326405096e1..88e7951ed9c 100644 --- a/staging/src/k8s.io/client-go/kubernetes/typed/flowcontrol/v1beta2/flowschema.go +++ b/staging/src/k8s.io/client-go/kubernetes/typed/flowcontrol/v1beta2/flowschema.go @@ -32,6 +32,8 @@ import ( scheme "k8s.io/client-go/kubernetes/scheme" rest "k8s.io/client-go/rest" consistencydetector "k8s.io/client-go/util/consistencydetector" + watchlist "k8s.io/client-go/util/watchlist" + "k8s.io/klog/v2" ) // FlowSchemasGetter has a method to return a FlowSchemaInterface. @@ -81,13 +83,22 @@ func (c *flowSchemas) Get(ctx context.Context, name string, options v1.GetOption } // List takes label and field selectors, and returns the list of FlowSchemas that match those selectors. -func (c *flowSchemas) List(ctx context.Context, opts v1.ListOptions) (result *v1beta2.FlowSchemaList, err error) { - defer func() { +func (c *flowSchemas) List(ctx context.Context, opts v1.ListOptions) (*v1beta2.FlowSchemaList, error) { + if watchListOptions, hasWatchListOptionsPrepared, watchListOptionsErr := watchlist.PrepareWatchListOptionsFromListOptions(opts); watchListOptionsErr != nil { + klog.Warningf("Failed preparing watchlist options for flowschemas, falling back to the standard LIST semantics, err = %v", watchListOptionsErr) + } else if hasWatchListOptionsPrepared { + result, err := c.watchList(ctx, watchListOptions) if err == nil { - consistencydetector.CheckListFromCacheDataConsistencyIfRequested(ctx, "list request for flowschemas", c.list, opts, result) + consistencydetector.CheckWatchListFromCacheDataConsistencyIfRequested(ctx, "watchlist request for flowschemas", c.list, opts, result) + return result, nil } - }() - return c.list(ctx, opts) + klog.Warningf("The watchlist request for flowschemas ended with an error, falling back to the standard LIST semantics, err = %v", err) + } + result, err := c.list(ctx, opts) + if err == nil { + consistencydetector.CheckListFromCacheDataConsistencyIfRequested(ctx, "list request for flowschemas", c.list, opts, result) + } + return result, err } // list takes label and field selectors, and returns the list of FlowSchemas that match those selectors. @@ -106,6 +117,22 @@ func (c *flowSchemas) list(ctx context.Context, opts v1.ListOptions) (result *v1 return } +// watchList establishes a watch stream with the server and returns the list of FlowSchemas +func (c *flowSchemas) watchList(ctx context.Context, opts v1.ListOptions) (result *v1beta2.FlowSchemaList, err error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + result = &v1beta2.FlowSchemaList{} + err = c.client.Get(). + Resource("flowschemas"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + WatchList(ctx). + Into(result) + return +} + // Watch returns a watch.Interface that watches the requested flowSchemas. func (c *flowSchemas) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { var timeout time.Duration diff --git a/staging/src/k8s.io/client-go/kubernetes/typed/flowcontrol/v1beta2/prioritylevelconfiguration.go b/staging/src/k8s.io/client-go/kubernetes/typed/flowcontrol/v1beta2/prioritylevelconfiguration.go index a1621fc2daa..e1cd0602449 100644 --- a/staging/src/k8s.io/client-go/kubernetes/typed/flowcontrol/v1beta2/prioritylevelconfiguration.go +++ b/staging/src/k8s.io/client-go/kubernetes/typed/flowcontrol/v1beta2/prioritylevelconfiguration.go @@ -32,6 +32,8 @@ import ( scheme "k8s.io/client-go/kubernetes/scheme" rest "k8s.io/client-go/rest" consistencydetector "k8s.io/client-go/util/consistencydetector" + watchlist "k8s.io/client-go/util/watchlist" + "k8s.io/klog/v2" ) // PriorityLevelConfigurationsGetter has a method to return a PriorityLevelConfigurationInterface. @@ -81,13 +83,22 @@ func (c *priorityLevelConfigurations) Get(ctx context.Context, name string, opti } // List takes label and field selectors, and returns the list of PriorityLevelConfigurations that match those selectors. -func (c *priorityLevelConfigurations) List(ctx context.Context, opts v1.ListOptions) (result *v1beta2.PriorityLevelConfigurationList, err error) { - defer func() { +func (c *priorityLevelConfigurations) List(ctx context.Context, opts v1.ListOptions) (*v1beta2.PriorityLevelConfigurationList, error) { + if watchListOptions, hasWatchListOptionsPrepared, watchListOptionsErr := watchlist.PrepareWatchListOptionsFromListOptions(opts); watchListOptionsErr != nil { + klog.Warningf("Failed preparing watchlist options for prioritylevelconfigurations, falling back to the standard LIST semantics, err = %v", watchListOptionsErr) + } else if hasWatchListOptionsPrepared { + result, err := c.watchList(ctx, watchListOptions) if err == nil { - consistencydetector.CheckListFromCacheDataConsistencyIfRequested(ctx, "list request for prioritylevelconfigurations", c.list, opts, result) + consistencydetector.CheckWatchListFromCacheDataConsistencyIfRequested(ctx, "watchlist request for prioritylevelconfigurations", c.list, opts, result) + return result, nil } - }() - return c.list(ctx, opts) + klog.Warningf("The watchlist request for prioritylevelconfigurations ended with an error, falling back to the standard LIST semantics, err = %v", err) + } + result, err := c.list(ctx, opts) + if err == nil { + consistencydetector.CheckListFromCacheDataConsistencyIfRequested(ctx, "list request for prioritylevelconfigurations", c.list, opts, result) + } + return result, err } // list takes label and field selectors, and returns the list of PriorityLevelConfigurations that match those selectors. @@ -106,6 +117,22 @@ func (c *priorityLevelConfigurations) list(ctx context.Context, opts v1.ListOpti return } +// watchList establishes a watch stream with the server and returns the list of PriorityLevelConfigurations +func (c *priorityLevelConfigurations) watchList(ctx context.Context, opts v1.ListOptions) (result *v1beta2.PriorityLevelConfigurationList, err error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + result = &v1beta2.PriorityLevelConfigurationList{} + err = c.client.Get(). + Resource("prioritylevelconfigurations"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + WatchList(ctx). + Into(result) + return +} + // Watch returns a watch.Interface that watches the requested priorityLevelConfigurations. func (c *priorityLevelConfigurations) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { var timeout time.Duration diff --git a/staging/src/k8s.io/client-go/kubernetes/typed/flowcontrol/v1beta3/flowschema.go b/staging/src/k8s.io/client-go/kubernetes/typed/flowcontrol/v1beta3/flowschema.go index 93bd3553217..1f61872e17f 100644 --- a/staging/src/k8s.io/client-go/kubernetes/typed/flowcontrol/v1beta3/flowschema.go +++ b/staging/src/k8s.io/client-go/kubernetes/typed/flowcontrol/v1beta3/flowschema.go @@ -32,6 +32,8 @@ import ( scheme "k8s.io/client-go/kubernetes/scheme" rest "k8s.io/client-go/rest" consistencydetector "k8s.io/client-go/util/consistencydetector" + watchlist "k8s.io/client-go/util/watchlist" + "k8s.io/klog/v2" ) // FlowSchemasGetter has a method to return a FlowSchemaInterface. @@ -81,13 +83,22 @@ func (c *flowSchemas) Get(ctx context.Context, name string, options v1.GetOption } // List takes label and field selectors, and returns the list of FlowSchemas that match those selectors. -func (c *flowSchemas) List(ctx context.Context, opts v1.ListOptions) (result *v1beta3.FlowSchemaList, err error) { - defer func() { +func (c *flowSchemas) List(ctx context.Context, opts v1.ListOptions) (*v1beta3.FlowSchemaList, error) { + if watchListOptions, hasWatchListOptionsPrepared, watchListOptionsErr := watchlist.PrepareWatchListOptionsFromListOptions(opts); watchListOptionsErr != nil { + klog.Warningf("Failed preparing watchlist options for flowschemas, falling back to the standard LIST semantics, err = %v", watchListOptionsErr) + } else if hasWatchListOptionsPrepared { + result, err := c.watchList(ctx, watchListOptions) if err == nil { - consistencydetector.CheckListFromCacheDataConsistencyIfRequested(ctx, "list request for flowschemas", c.list, opts, result) + consistencydetector.CheckWatchListFromCacheDataConsistencyIfRequested(ctx, "watchlist request for flowschemas", c.list, opts, result) + return result, nil } - }() - return c.list(ctx, opts) + klog.Warningf("The watchlist request for flowschemas ended with an error, falling back to the standard LIST semantics, err = %v", err) + } + result, err := c.list(ctx, opts) + if err == nil { + consistencydetector.CheckListFromCacheDataConsistencyIfRequested(ctx, "list request for flowschemas", c.list, opts, result) + } + return result, err } // list takes label and field selectors, and returns the list of FlowSchemas that match those selectors. @@ -106,6 +117,22 @@ func (c *flowSchemas) list(ctx context.Context, opts v1.ListOptions) (result *v1 return } +// watchList establishes a watch stream with the server and returns the list of FlowSchemas +func (c *flowSchemas) watchList(ctx context.Context, opts v1.ListOptions) (result *v1beta3.FlowSchemaList, err error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + result = &v1beta3.FlowSchemaList{} + err = c.client.Get(). + Resource("flowschemas"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + WatchList(ctx). + Into(result) + return +} + // Watch returns a watch.Interface that watches the requested flowSchemas. func (c *flowSchemas) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { var timeout time.Duration diff --git a/staging/src/k8s.io/client-go/kubernetes/typed/flowcontrol/v1beta3/prioritylevelconfiguration.go b/staging/src/k8s.io/client-go/kubernetes/typed/flowcontrol/v1beta3/prioritylevelconfiguration.go index d419be5f8a8..c8341278777 100644 --- a/staging/src/k8s.io/client-go/kubernetes/typed/flowcontrol/v1beta3/prioritylevelconfiguration.go +++ b/staging/src/k8s.io/client-go/kubernetes/typed/flowcontrol/v1beta3/prioritylevelconfiguration.go @@ -32,6 +32,8 @@ import ( scheme "k8s.io/client-go/kubernetes/scheme" rest "k8s.io/client-go/rest" consistencydetector "k8s.io/client-go/util/consistencydetector" + watchlist "k8s.io/client-go/util/watchlist" + "k8s.io/klog/v2" ) // PriorityLevelConfigurationsGetter has a method to return a PriorityLevelConfigurationInterface. @@ -81,13 +83,22 @@ func (c *priorityLevelConfigurations) Get(ctx context.Context, name string, opti } // List takes label and field selectors, and returns the list of PriorityLevelConfigurations that match those selectors. -func (c *priorityLevelConfigurations) List(ctx context.Context, opts v1.ListOptions) (result *v1beta3.PriorityLevelConfigurationList, err error) { - defer func() { +func (c *priorityLevelConfigurations) List(ctx context.Context, opts v1.ListOptions) (*v1beta3.PriorityLevelConfigurationList, error) { + if watchListOptions, hasWatchListOptionsPrepared, watchListOptionsErr := watchlist.PrepareWatchListOptionsFromListOptions(opts); watchListOptionsErr != nil { + klog.Warningf("Failed preparing watchlist options for prioritylevelconfigurations, falling back to the standard LIST semantics, err = %v", watchListOptionsErr) + } else if hasWatchListOptionsPrepared { + result, err := c.watchList(ctx, watchListOptions) if err == nil { - consistencydetector.CheckListFromCacheDataConsistencyIfRequested(ctx, "list request for prioritylevelconfigurations", c.list, opts, result) + consistencydetector.CheckWatchListFromCacheDataConsistencyIfRequested(ctx, "watchlist request for prioritylevelconfigurations", c.list, opts, result) + return result, nil } - }() - return c.list(ctx, opts) + klog.Warningf("The watchlist request for prioritylevelconfigurations ended with an error, falling back to the standard LIST semantics, err = %v", err) + } + result, err := c.list(ctx, opts) + if err == nil { + consistencydetector.CheckListFromCacheDataConsistencyIfRequested(ctx, "list request for prioritylevelconfigurations", c.list, opts, result) + } + return result, err } // list takes label and field selectors, and returns the list of PriorityLevelConfigurations that match those selectors. @@ -106,6 +117,22 @@ func (c *priorityLevelConfigurations) list(ctx context.Context, opts v1.ListOpti return } +// watchList establishes a watch stream with the server and returns the list of PriorityLevelConfigurations +func (c *priorityLevelConfigurations) watchList(ctx context.Context, opts v1.ListOptions) (result *v1beta3.PriorityLevelConfigurationList, err error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + result = &v1beta3.PriorityLevelConfigurationList{} + err = c.client.Get(). + Resource("prioritylevelconfigurations"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + WatchList(ctx). + Into(result) + return +} + // Watch returns a watch.Interface that watches the requested priorityLevelConfigurations. func (c *priorityLevelConfigurations) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { var timeout time.Duration diff --git a/staging/src/k8s.io/client-go/kubernetes/typed/networking/v1/ingress.go b/staging/src/k8s.io/client-go/kubernetes/typed/networking/v1/ingress.go index dbdf32b90cc..bb87b1c9f12 100644 --- a/staging/src/k8s.io/client-go/kubernetes/typed/networking/v1/ingress.go +++ b/staging/src/k8s.io/client-go/kubernetes/typed/networking/v1/ingress.go @@ -32,6 +32,8 @@ import ( scheme "k8s.io/client-go/kubernetes/scheme" rest "k8s.io/client-go/rest" consistencydetector "k8s.io/client-go/util/consistencydetector" + watchlist "k8s.io/client-go/util/watchlist" + "k8s.io/klog/v2" ) // IngressesGetter has a method to return a IngressInterface. @@ -84,13 +86,22 @@ func (c *ingresses) Get(ctx context.Context, name string, options metav1.GetOpti } // List takes label and field selectors, and returns the list of Ingresses that match those selectors. -func (c *ingresses) List(ctx context.Context, opts metav1.ListOptions) (result *v1.IngressList, err error) { - defer func() { +func (c *ingresses) List(ctx context.Context, opts metav1.ListOptions) (*v1.IngressList, error) { + if watchListOptions, hasWatchListOptionsPrepared, watchListOptionsErr := watchlist.PrepareWatchListOptionsFromListOptions(opts); watchListOptionsErr != nil { + klog.Warningf("Failed preparing watchlist options for ingresses, falling back to the standard LIST semantics, err = %v", watchListOptionsErr) + } else if hasWatchListOptionsPrepared { + result, err := c.watchList(ctx, watchListOptions) if err == nil { - consistencydetector.CheckListFromCacheDataConsistencyIfRequested(ctx, "list request for ingresses", c.list, opts, result) + consistencydetector.CheckWatchListFromCacheDataConsistencyIfRequested(ctx, "watchlist request for ingresses", c.list, opts, result) + return result, nil } - }() - return c.list(ctx, opts) + klog.Warningf("The watchlist request for ingresses ended with an error, falling back to the standard LIST semantics, err = %v", err) + } + result, err := c.list(ctx, opts) + if err == nil { + consistencydetector.CheckListFromCacheDataConsistencyIfRequested(ctx, "list request for ingresses", c.list, opts, result) + } + return result, err } // list takes label and field selectors, and returns the list of Ingresses that match those selectors. @@ -110,6 +121,23 @@ func (c *ingresses) list(ctx context.Context, opts metav1.ListOptions) (result * return } +// watchList establishes a watch stream with the server and returns the list of Ingresses +func (c *ingresses) watchList(ctx context.Context, opts metav1.ListOptions) (result *v1.IngressList, err error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + result = &v1.IngressList{} + err = c.client.Get(). + Namespace(c.ns). + Resource("ingresses"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + WatchList(ctx). + Into(result) + return +} + // Watch returns a watch.Interface that watches the requested ingresses. func (c *ingresses) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { var timeout time.Duration diff --git a/staging/src/k8s.io/client-go/kubernetes/typed/networking/v1/ingressclass.go b/staging/src/k8s.io/client-go/kubernetes/typed/networking/v1/ingressclass.go index 4ca832c90b7..22de5240baa 100644 --- a/staging/src/k8s.io/client-go/kubernetes/typed/networking/v1/ingressclass.go +++ b/staging/src/k8s.io/client-go/kubernetes/typed/networking/v1/ingressclass.go @@ -32,6 +32,8 @@ import ( scheme "k8s.io/client-go/kubernetes/scheme" rest "k8s.io/client-go/rest" consistencydetector "k8s.io/client-go/util/consistencydetector" + watchlist "k8s.io/client-go/util/watchlist" + "k8s.io/klog/v2" ) // IngressClassesGetter has a method to return a IngressClassInterface. @@ -79,13 +81,22 @@ func (c *ingressClasses) Get(ctx context.Context, name string, options metav1.Ge } // List takes label and field selectors, and returns the list of IngressClasses that match those selectors. -func (c *ingressClasses) List(ctx context.Context, opts metav1.ListOptions) (result *v1.IngressClassList, err error) { - defer func() { +func (c *ingressClasses) List(ctx context.Context, opts metav1.ListOptions) (*v1.IngressClassList, error) { + if watchListOptions, hasWatchListOptionsPrepared, watchListOptionsErr := watchlist.PrepareWatchListOptionsFromListOptions(opts); watchListOptionsErr != nil { + klog.Warningf("Failed preparing watchlist options for ingressclasses, falling back to the standard LIST semantics, err = %v", watchListOptionsErr) + } else if hasWatchListOptionsPrepared { + result, err := c.watchList(ctx, watchListOptions) if err == nil { - consistencydetector.CheckListFromCacheDataConsistencyIfRequested(ctx, "list request for ingressclasses", c.list, opts, result) + consistencydetector.CheckWatchListFromCacheDataConsistencyIfRequested(ctx, "watchlist request for ingressclasses", c.list, opts, result) + return result, nil } - }() - return c.list(ctx, opts) + klog.Warningf("The watchlist request for ingressclasses ended with an error, falling back to the standard LIST semantics, err = %v", err) + } + result, err := c.list(ctx, opts) + if err == nil { + consistencydetector.CheckListFromCacheDataConsistencyIfRequested(ctx, "list request for ingressclasses", c.list, opts, result) + } + return result, err } // list takes label and field selectors, and returns the list of IngressClasses that match those selectors. @@ -104,6 +115,22 @@ func (c *ingressClasses) list(ctx context.Context, opts metav1.ListOptions) (res return } +// watchList establishes a watch stream with the server and returns the list of IngressClasses +func (c *ingressClasses) watchList(ctx context.Context, opts metav1.ListOptions) (result *v1.IngressClassList, err error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + result = &v1.IngressClassList{} + err = c.client.Get(). + Resource("ingressclasses"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + WatchList(ctx). + Into(result) + return +} + // Watch returns a watch.Interface that watches the requested ingressClasses. func (c *ingressClasses) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { var timeout time.Duration diff --git a/staging/src/k8s.io/client-go/kubernetes/typed/networking/v1/networkpolicy.go b/staging/src/k8s.io/client-go/kubernetes/typed/networking/v1/networkpolicy.go index 1fd8bd03477..1fcd8582580 100644 --- a/staging/src/k8s.io/client-go/kubernetes/typed/networking/v1/networkpolicy.go +++ b/staging/src/k8s.io/client-go/kubernetes/typed/networking/v1/networkpolicy.go @@ -32,6 +32,8 @@ import ( scheme "k8s.io/client-go/kubernetes/scheme" rest "k8s.io/client-go/rest" consistencydetector "k8s.io/client-go/util/consistencydetector" + watchlist "k8s.io/client-go/util/watchlist" + "k8s.io/klog/v2" ) // NetworkPoliciesGetter has a method to return a NetworkPolicyInterface. @@ -82,13 +84,22 @@ func (c *networkPolicies) Get(ctx context.Context, name string, options metav1.G } // List takes label and field selectors, and returns the list of NetworkPolicies that match those selectors. -func (c *networkPolicies) List(ctx context.Context, opts metav1.ListOptions) (result *v1.NetworkPolicyList, err error) { - defer func() { +func (c *networkPolicies) List(ctx context.Context, opts metav1.ListOptions) (*v1.NetworkPolicyList, error) { + if watchListOptions, hasWatchListOptionsPrepared, watchListOptionsErr := watchlist.PrepareWatchListOptionsFromListOptions(opts); watchListOptionsErr != nil { + klog.Warningf("Failed preparing watchlist options for networkpolicies, falling back to the standard LIST semantics, err = %v", watchListOptionsErr) + } else if hasWatchListOptionsPrepared { + result, err := c.watchList(ctx, watchListOptions) if err == nil { - consistencydetector.CheckListFromCacheDataConsistencyIfRequested(ctx, "list request for networkpolicies", c.list, opts, result) + consistencydetector.CheckWatchListFromCacheDataConsistencyIfRequested(ctx, "watchlist request for networkpolicies", c.list, opts, result) + return result, nil } - }() - return c.list(ctx, opts) + klog.Warningf("The watchlist request for networkpolicies ended with an error, falling back to the standard LIST semantics, err = %v", err) + } + result, err := c.list(ctx, opts) + if err == nil { + consistencydetector.CheckListFromCacheDataConsistencyIfRequested(ctx, "list request for networkpolicies", c.list, opts, result) + } + return result, err } // list takes label and field selectors, and returns the list of NetworkPolicies that match those selectors. @@ -108,6 +119,23 @@ func (c *networkPolicies) list(ctx context.Context, opts metav1.ListOptions) (re return } +// watchList establishes a watch stream with the server and returns the list of NetworkPolicies +func (c *networkPolicies) watchList(ctx context.Context, opts metav1.ListOptions) (result *v1.NetworkPolicyList, err error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + result = &v1.NetworkPolicyList{} + err = c.client.Get(). + Namespace(c.ns). + Resource("networkpolicies"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + WatchList(ctx). + Into(result) + return +} + // Watch returns a watch.Interface that watches the requested networkPolicies. func (c *networkPolicies) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { var timeout time.Duration diff --git a/staging/src/k8s.io/client-go/kubernetes/typed/networking/v1alpha1/ipaddress.go b/staging/src/k8s.io/client-go/kubernetes/typed/networking/v1alpha1/ipaddress.go index fcf63fc85ea..c942f1c4861 100644 --- a/staging/src/k8s.io/client-go/kubernetes/typed/networking/v1alpha1/ipaddress.go +++ b/staging/src/k8s.io/client-go/kubernetes/typed/networking/v1alpha1/ipaddress.go @@ -32,6 +32,8 @@ import ( scheme "k8s.io/client-go/kubernetes/scheme" rest "k8s.io/client-go/rest" consistencydetector "k8s.io/client-go/util/consistencydetector" + watchlist "k8s.io/client-go/util/watchlist" + "k8s.io/klog/v2" ) // IPAddressesGetter has a method to return a IPAddressInterface. @@ -79,13 +81,22 @@ func (c *iPAddresses) Get(ctx context.Context, name string, options v1.GetOption } // List takes label and field selectors, and returns the list of IPAddresses that match those selectors. -func (c *iPAddresses) List(ctx context.Context, opts v1.ListOptions) (result *v1alpha1.IPAddressList, err error) { - defer func() { +func (c *iPAddresses) List(ctx context.Context, opts v1.ListOptions) (*v1alpha1.IPAddressList, error) { + if watchListOptions, hasWatchListOptionsPrepared, watchListOptionsErr := watchlist.PrepareWatchListOptionsFromListOptions(opts); watchListOptionsErr != nil { + klog.Warningf("Failed preparing watchlist options for ipaddresses, falling back to the standard LIST semantics, err = %v", watchListOptionsErr) + } else if hasWatchListOptionsPrepared { + result, err := c.watchList(ctx, watchListOptions) if err == nil { - consistencydetector.CheckListFromCacheDataConsistencyIfRequested(ctx, "list request for ipaddresses", c.list, opts, result) + consistencydetector.CheckWatchListFromCacheDataConsistencyIfRequested(ctx, "watchlist request for ipaddresses", c.list, opts, result) + return result, nil } - }() - return c.list(ctx, opts) + klog.Warningf("The watchlist request for ipaddresses ended with an error, falling back to the standard LIST semantics, err = %v", err) + } + result, err := c.list(ctx, opts) + if err == nil { + consistencydetector.CheckListFromCacheDataConsistencyIfRequested(ctx, "list request for ipaddresses", c.list, opts, result) + } + return result, err } // list takes label and field selectors, and returns the list of IPAddresses that match those selectors. @@ -104,6 +115,22 @@ func (c *iPAddresses) list(ctx context.Context, opts v1.ListOptions) (result *v1 return } +// watchList establishes a watch stream with the server and returns the list of IPAddresses +func (c *iPAddresses) watchList(ctx context.Context, opts v1.ListOptions) (result *v1alpha1.IPAddressList, err error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + result = &v1alpha1.IPAddressList{} + err = c.client.Get(). + Resource("ipaddresses"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + WatchList(ctx). + Into(result) + return +} + // Watch returns a watch.Interface that watches the requested iPAddresses. func (c *iPAddresses) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { var timeout time.Duration diff --git a/staging/src/k8s.io/client-go/kubernetes/typed/networking/v1alpha1/servicecidr.go b/staging/src/k8s.io/client-go/kubernetes/typed/networking/v1alpha1/servicecidr.go index 392f30d2e36..b3a81ffd23d 100644 --- a/staging/src/k8s.io/client-go/kubernetes/typed/networking/v1alpha1/servicecidr.go +++ b/staging/src/k8s.io/client-go/kubernetes/typed/networking/v1alpha1/servicecidr.go @@ -32,6 +32,8 @@ import ( scheme "k8s.io/client-go/kubernetes/scheme" rest "k8s.io/client-go/rest" consistencydetector "k8s.io/client-go/util/consistencydetector" + watchlist "k8s.io/client-go/util/watchlist" + "k8s.io/klog/v2" ) // ServiceCIDRsGetter has a method to return a ServiceCIDRInterface. @@ -81,13 +83,22 @@ func (c *serviceCIDRs) Get(ctx context.Context, name string, options v1.GetOptio } // List takes label and field selectors, and returns the list of ServiceCIDRs that match those selectors. -func (c *serviceCIDRs) List(ctx context.Context, opts v1.ListOptions) (result *v1alpha1.ServiceCIDRList, err error) { - defer func() { +func (c *serviceCIDRs) List(ctx context.Context, opts v1.ListOptions) (*v1alpha1.ServiceCIDRList, error) { + if watchListOptions, hasWatchListOptionsPrepared, watchListOptionsErr := watchlist.PrepareWatchListOptionsFromListOptions(opts); watchListOptionsErr != nil { + klog.Warningf("Failed preparing watchlist options for servicecidrs, falling back to the standard LIST semantics, err = %v", watchListOptionsErr) + } else if hasWatchListOptionsPrepared { + result, err := c.watchList(ctx, watchListOptions) if err == nil { - consistencydetector.CheckListFromCacheDataConsistencyIfRequested(ctx, "list request for servicecidrs", c.list, opts, result) + consistencydetector.CheckWatchListFromCacheDataConsistencyIfRequested(ctx, "watchlist request for servicecidrs", c.list, opts, result) + return result, nil } - }() - return c.list(ctx, opts) + klog.Warningf("The watchlist request for servicecidrs ended with an error, falling back to the standard LIST semantics, err = %v", err) + } + result, err := c.list(ctx, opts) + if err == nil { + consistencydetector.CheckListFromCacheDataConsistencyIfRequested(ctx, "list request for servicecidrs", c.list, opts, result) + } + return result, err } // list takes label and field selectors, and returns the list of ServiceCIDRs that match those selectors. @@ -106,6 +117,22 @@ func (c *serviceCIDRs) list(ctx context.Context, opts v1.ListOptions) (result *v return } +// watchList establishes a watch stream with the server and returns the list of ServiceCIDRs +func (c *serviceCIDRs) watchList(ctx context.Context, opts v1.ListOptions) (result *v1alpha1.ServiceCIDRList, err error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + result = &v1alpha1.ServiceCIDRList{} + err = c.client.Get(). + Resource("servicecidrs"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + WatchList(ctx). + Into(result) + return +} + // Watch returns a watch.Interface that watches the requested serviceCIDRs. func (c *serviceCIDRs) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { var timeout time.Duration diff --git a/staging/src/k8s.io/client-go/kubernetes/typed/networking/v1beta1/ingress.go b/staging/src/k8s.io/client-go/kubernetes/typed/networking/v1beta1/ingress.go index 92df698e8d1..e4b9b4a5cd8 100644 --- a/staging/src/k8s.io/client-go/kubernetes/typed/networking/v1beta1/ingress.go +++ b/staging/src/k8s.io/client-go/kubernetes/typed/networking/v1beta1/ingress.go @@ -32,6 +32,8 @@ import ( scheme "k8s.io/client-go/kubernetes/scheme" rest "k8s.io/client-go/rest" consistencydetector "k8s.io/client-go/util/consistencydetector" + watchlist "k8s.io/client-go/util/watchlist" + "k8s.io/klog/v2" ) // IngressesGetter has a method to return a IngressInterface. @@ -84,13 +86,22 @@ func (c *ingresses) Get(ctx context.Context, name string, options v1.GetOptions) } // List takes label and field selectors, and returns the list of Ingresses that match those selectors. -func (c *ingresses) List(ctx context.Context, opts v1.ListOptions) (result *v1beta1.IngressList, err error) { - defer func() { +func (c *ingresses) List(ctx context.Context, opts v1.ListOptions) (*v1beta1.IngressList, error) { + if watchListOptions, hasWatchListOptionsPrepared, watchListOptionsErr := watchlist.PrepareWatchListOptionsFromListOptions(opts); watchListOptionsErr != nil { + klog.Warningf("Failed preparing watchlist options for ingresses, falling back to the standard LIST semantics, err = %v", watchListOptionsErr) + } else if hasWatchListOptionsPrepared { + result, err := c.watchList(ctx, watchListOptions) if err == nil { - consistencydetector.CheckListFromCacheDataConsistencyIfRequested(ctx, "list request for ingresses", c.list, opts, result) + consistencydetector.CheckWatchListFromCacheDataConsistencyIfRequested(ctx, "watchlist request for ingresses", c.list, opts, result) + return result, nil } - }() - return c.list(ctx, opts) + klog.Warningf("The watchlist request for ingresses ended with an error, falling back to the standard LIST semantics, err = %v", err) + } + result, err := c.list(ctx, opts) + if err == nil { + consistencydetector.CheckListFromCacheDataConsistencyIfRequested(ctx, "list request for ingresses", c.list, opts, result) + } + return result, err } // list takes label and field selectors, and returns the list of Ingresses that match those selectors. @@ -110,6 +121,23 @@ func (c *ingresses) list(ctx context.Context, opts v1.ListOptions) (result *v1be return } +// watchList establishes a watch stream with the server and returns the list of Ingresses +func (c *ingresses) watchList(ctx context.Context, opts v1.ListOptions) (result *v1beta1.IngressList, err error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + result = &v1beta1.IngressList{} + err = c.client.Get(). + Namespace(c.ns). + Resource("ingresses"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + WatchList(ctx). + Into(result) + return +} + // Watch returns a watch.Interface that watches the requested ingresses. func (c *ingresses) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { var timeout time.Duration diff --git a/staging/src/k8s.io/client-go/kubernetes/typed/networking/v1beta1/ingressclass.go b/staging/src/k8s.io/client-go/kubernetes/typed/networking/v1beta1/ingressclass.go index 577a4d87e25..1591e8d5891 100644 --- a/staging/src/k8s.io/client-go/kubernetes/typed/networking/v1beta1/ingressclass.go +++ b/staging/src/k8s.io/client-go/kubernetes/typed/networking/v1beta1/ingressclass.go @@ -32,6 +32,8 @@ import ( scheme "k8s.io/client-go/kubernetes/scheme" rest "k8s.io/client-go/rest" consistencydetector "k8s.io/client-go/util/consistencydetector" + watchlist "k8s.io/client-go/util/watchlist" + "k8s.io/klog/v2" ) // IngressClassesGetter has a method to return a IngressClassInterface. @@ -79,13 +81,22 @@ func (c *ingressClasses) Get(ctx context.Context, name string, options v1.GetOpt } // List takes label and field selectors, and returns the list of IngressClasses that match those selectors. -func (c *ingressClasses) List(ctx context.Context, opts v1.ListOptions) (result *v1beta1.IngressClassList, err error) { - defer func() { +func (c *ingressClasses) List(ctx context.Context, opts v1.ListOptions) (*v1beta1.IngressClassList, error) { + if watchListOptions, hasWatchListOptionsPrepared, watchListOptionsErr := watchlist.PrepareWatchListOptionsFromListOptions(opts); watchListOptionsErr != nil { + klog.Warningf("Failed preparing watchlist options for ingressclasses, falling back to the standard LIST semantics, err = %v", watchListOptionsErr) + } else if hasWatchListOptionsPrepared { + result, err := c.watchList(ctx, watchListOptions) if err == nil { - consistencydetector.CheckListFromCacheDataConsistencyIfRequested(ctx, "list request for ingressclasses", c.list, opts, result) + consistencydetector.CheckWatchListFromCacheDataConsistencyIfRequested(ctx, "watchlist request for ingressclasses", c.list, opts, result) + return result, nil } - }() - return c.list(ctx, opts) + klog.Warningf("The watchlist request for ingressclasses ended with an error, falling back to the standard LIST semantics, err = %v", err) + } + result, err := c.list(ctx, opts) + if err == nil { + consistencydetector.CheckListFromCacheDataConsistencyIfRequested(ctx, "list request for ingressclasses", c.list, opts, result) + } + return result, err } // list takes label and field selectors, and returns the list of IngressClasses that match those selectors. @@ -104,6 +115,22 @@ func (c *ingressClasses) list(ctx context.Context, opts v1.ListOptions) (result return } +// watchList establishes a watch stream with the server and returns the list of IngressClasses +func (c *ingressClasses) watchList(ctx context.Context, opts v1.ListOptions) (result *v1beta1.IngressClassList, err error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + result = &v1beta1.IngressClassList{} + err = c.client.Get(). + Resource("ingressclasses"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + WatchList(ctx). + Into(result) + return +} + // Watch returns a watch.Interface that watches the requested ingressClasses. func (c *ingressClasses) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { var timeout time.Duration diff --git a/staging/src/k8s.io/client-go/kubernetes/typed/node/v1/runtimeclass.go b/staging/src/k8s.io/client-go/kubernetes/typed/node/v1/runtimeclass.go index c8911b1e676..7b86fe90972 100644 --- a/staging/src/k8s.io/client-go/kubernetes/typed/node/v1/runtimeclass.go +++ b/staging/src/k8s.io/client-go/kubernetes/typed/node/v1/runtimeclass.go @@ -32,6 +32,8 @@ import ( scheme "k8s.io/client-go/kubernetes/scheme" rest "k8s.io/client-go/rest" consistencydetector "k8s.io/client-go/util/consistencydetector" + watchlist "k8s.io/client-go/util/watchlist" + "k8s.io/klog/v2" ) // RuntimeClassesGetter has a method to return a RuntimeClassInterface. @@ -79,13 +81,22 @@ func (c *runtimeClasses) Get(ctx context.Context, name string, options metav1.Ge } // List takes label and field selectors, and returns the list of RuntimeClasses that match those selectors. -func (c *runtimeClasses) List(ctx context.Context, opts metav1.ListOptions) (result *v1.RuntimeClassList, err error) { - defer func() { +func (c *runtimeClasses) List(ctx context.Context, opts metav1.ListOptions) (*v1.RuntimeClassList, error) { + if watchListOptions, hasWatchListOptionsPrepared, watchListOptionsErr := watchlist.PrepareWatchListOptionsFromListOptions(opts); watchListOptionsErr != nil { + klog.Warningf("Failed preparing watchlist options for runtimeclasses, falling back to the standard LIST semantics, err = %v", watchListOptionsErr) + } else if hasWatchListOptionsPrepared { + result, err := c.watchList(ctx, watchListOptions) if err == nil { - consistencydetector.CheckListFromCacheDataConsistencyIfRequested(ctx, "list request for runtimeclasses", c.list, opts, result) + consistencydetector.CheckWatchListFromCacheDataConsistencyIfRequested(ctx, "watchlist request for runtimeclasses", c.list, opts, result) + return result, nil } - }() - return c.list(ctx, opts) + klog.Warningf("The watchlist request for runtimeclasses ended with an error, falling back to the standard LIST semantics, err = %v", err) + } + result, err := c.list(ctx, opts) + if err == nil { + consistencydetector.CheckListFromCacheDataConsistencyIfRequested(ctx, "list request for runtimeclasses", c.list, opts, result) + } + return result, err } // list takes label and field selectors, and returns the list of RuntimeClasses that match those selectors. @@ -104,6 +115,22 @@ func (c *runtimeClasses) list(ctx context.Context, opts metav1.ListOptions) (res return } +// watchList establishes a watch stream with the server and returns the list of RuntimeClasses +func (c *runtimeClasses) watchList(ctx context.Context, opts metav1.ListOptions) (result *v1.RuntimeClassList, err error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + result = &v1.RuntimeClassList{} + err = c.client.Get(). + Resource("runtimeclasses"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + WatchList(ctx). + Into(result) + return +} + // Watch returns a watch.Interface that watches the requested runtimeClasses. func (c *runtimeClasses) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { var timeout time.Duration diff --git a/staging/src/k8s.io/client-go/kubernetes/typed/node/v1alpha1/runtimeclass.go b/staging/src/k8s.io/client-go/kubernetes/typed/node/v1alpha1/runtimeclass.go index c9fdaae5ade..1df0b590431 100644 --- a/staging/src/k8s.io/client-go/kubernetes/typed/node/v1alpha1/runtimeclass.go +++ b/staging/src/k8s.io/client-go/kubernetes/typed/node/v1alpha1/runtimeclass.go @@ -32,6 +32,8 @@ import ( scheme "k8s.io/client-go/kubernetes/scheme" rest "k8s.io/client-go/rest" consistencydetector "k8s.io/client-go/util/consistencydetector" + watchlist "k8s.io/client-go/util/watchlist" + "k8s.io/klog/v2" ) // RuntimeClassesGetter has a method to return a RuntimeClassInterface. @@ -79,13 +81,22 @@ func (c *runtimeClasses) Get(ctx context.Context, name string, options v1.GetOpt } // List takes label and field selectors, and returns the list of RuntimeClasses that match those selectors. -func (c *runtimeClasses) List(ctx context.Context, opts v1.ListOptions) (result *v1alpha1.RuntimeClassList, err error) { - defer func() { +func (c *runtimeClasses) List(ctx context.Context, opts v1.ListOptions) (*v1alpha1.RuntimeClassList, error) { + if watchListOptions, hasWatchListOptionsPrepared, watchListOptionsErr := watchlist.PrepareWatchListOptionsFromListOptions(opts); watchListOptionsErr != nil { + klog.Warningf("Failed preparing watchlist options for runtimeclasses, falling back to the standard LIST semantics, err = %v", watchListOptionsErr) + } else if hasWatchListOptionsPrepared { + result, err := c.watchList(ctx, watchListOptions) if err == nil { - consistencydetector.CheckListFromCacheDataConsistencyIfRequested(ctx, "list request for runtimeclasses", c.list, opts, result) + consistencydetector.CheckWatchListFromCacheDataConsistencyIfRequested(ctx, "watchlist request for runtimeclasses", c.list, opts, result) + return result, nil } - }() - return c.list(ctx, opts) + klog.Warningf("The watchlist request for runtimeclasses ended with an error, falling back to the standard LIST semantics, err = %v", err) + } + result, err := c.list(ctx, opts) + if err == nil { + consistencydetector.CheckListFromCacheDataConsistencyIfRequested(ctx, "list request for runtimeclasses", c.list, opts, result) + } + return result, err } // list takes label and field selectors, and returns the list of RuntimeClasses that match those selectors. @@ -104,6 +115,22 @@ func (c *runtimeClasses) list(ctx context.Context, opts v1.ListOptions) (result return } +// watchList establishes a watch stream with the server and returns the list of RuntimeClasses +func (c *runtimeClasses) watchList(ctx context.Context, opts v1.ListOptions) (result *v1alpha1.RuntimeClassList, err error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + result = &v1alpha1.RuntimeClassList{} + err = c.client.Get(). + Resource("runtimeclasses"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + WatchList(ctx). + Into(result) + return +} + // Watch returns a watch.Interface that watches the requested runtimeClasses. func (c *runtimeClasses) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { var timeout time.Duration diff --git a/staging/src/k8s.io/client-go/kubernetes/typed/node/v1beta1/runtimeclass.go b/staging/src/k8s.io/client-go/kubernetes/typed/node/v1beta1/runtimeclass.go index 341a1e0969c..cf5f95ecd23 100644 --- a/staging/src/k8s.io/client-go/kubernetes/typed/node/v1beta1/runtimeclass.go +++ b/staging/src/k8s.io/client-go/kubernetes/typed/node/v1beta1/runtimeclass.go @@ -32,6 +32,8 @@ import ( scheme "k8s.io/client-go/kubernetes/scheme" rest "k8s.io/client-go/rest" consistencydetector "k8s.io/client-go/util/consistencydetector" + watchlist "k8s.io/client-go/util/watchlist" + "k8s.io/klog/v2" ) // RuntimeClassesGetter has a method to return a RuntimeClassInterface. @@ -79,13 +81,22 @@ func (c *runtimeClasses) Get(ctx context.Context, name string, options v1.GetOpt } // List takes label and field selectors, and returns the list of RuntimeClasses that match those selectors. -func (c *runtimeClasses) List(ctx context.Context, opts v1.ListOptions) (result *v1beta1.RuntimeClassList, err error) { - defer func() { +func (c *runtimeClasses) List(ctx context.Context, opts v1.ListOptions) (*v1beta1.RuntimeClassList, error) { + if watchListOptions, hasWatchListOptionsPrepared, watchListOptionsErr := watchlist.PrepareWatchListOptionsFromListOptions(opts); watchListOptionsErr != nil { + klog.Warningf("Failed preparing watchlist options for runtimeclasses, falling back to the standard LIST semantics, err = %v", watchListOptionsErr) + } else if hasWatchListOptionsPrepared { + result, err := c.watchList(ctx, watchListOptions) if err == nil { - consistencydetector.CheckListFromCacheDataConsistencyIfRequested(ctx, "list request for runtimeclasses", c.list, opts, result) + consistencydetector.CheckWatchListFromCacheDataConsistencyIfRequested(ctx, "watchlist request for runtimeclasses", c.list, opts, result) + return result, nil } - }() - return c.list(ctx, opts) + klog.Warningf("The watchlist request for runtimeclasses ended with an error, falling back to the standard LIST semantics, err = %v", err) + } + result, err := c.list(ctx, opts) + if err == nil { + consistencydetector.CheckListFromCacheDataConsistencyIfRequested(ctx, "list request for runtimeclasses", c.list, opts, result) + } + return result, err } // list takes label and field selectors, and returns the list of RuntimeClasses that match those selectors. @@ -104,6 +115,22 @@ func (c *runtimeClasses) list(ctx context.Context, opts v1.ListOptions) (result return } +// watchList establishes a watch stream with the server and returns the list of RuntimeClasses +func (c *runtimeClasses) watchList(ctx context.Context, opts v1.ListOptions) (result *v1beta1.RuntimeClassList, err error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + result = &v1beta1.RuntimeClassList{} + err = c.client.Get(). + Resource("runtimeclasses"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + WatchList(ctx). + Into(result) + return +} + // Watch returns a watch.Interface that watches the requested runtimeClasses. func (c *runtimeClasses) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { var timeout time.Duration diff --git a/staging/src/k8s.io/client-go/kubernetes/typed/policy/v1/poddisruptionbudget.go b/staging/src/k8s.io/client-go/kubernetes/typed/policy/v1/poddisruptionbudget.go index 37d93a2b254..f629d67ef5e 100644 --- a/staging/src/k8s.io/client-go/kubernetes/typed/policy/v1/poddisruptionbudget.go +++ b/staging/src/k8s.io/client-go/kubernetes/typed/policy/v1/poddisruptionbudget.go @@ -32,6 +32,8 @@ import ( scheme "k8s.io/client-go/kubernetes/scheme" rest "k8s.io/client-go/rest" consistencydetector "k8s.io/client-go/util/consistencydetector" + watchlist "k8s.io/client-go/util/watchlist" + "k8s.io/klog/v2" ) // PodDisruptionBudgetsGetter has a method to return a PodDisruptionBudgetInterface. @@ -84,13 +86,22 @@ func (c *podDisruptionBudgets) Get(ctx context.Context, name string, options met } // List takes label and field selectors, and returns the list of PodDisruptionBudgets that match those selectors. -func (c *podDisruptionBudgets) List(ctx context.Context, opts metav1.ListOptions) (result *v1.PodDisruptionBudgetList, err error) { - defer func() { +func (c *podDisruptionBudgets) List(ctx context.Context, opts metav1.ListOptions) (*v1.PodDisruptionBudgetList, error) { + if watchListOptions, hasWatchListOptionsPrepared, watchListOptionsErr := watchlist.PrepareWatchListOptionsFromListOptions(opts); watchListOptionsErr != nil { + klog.Warningf("Failed preparing watchlist options for poddisruptionbudgets, falling back to the standard LIST semantics, err = %v", watchListOptionsErr) + } else if hasWatchListOptionsPrepared { + result, err := c.watchList(ctx, watchListOptions) if err == nil { - consistencydetector.CheckListFromCacheDataConsistencyIfRequested(ctx, "list request for poddisruptionbudgets", c.list, opts, result) + consistencydetector.CheckWatchListFromCacheDataConsistencyIfRequested(ctx, "watchlist request for poddisruptionbudgets", c.list, opts, result) + return result, nil } - }() - return c.list(ctx, opts) + klog.Warningf("The watchlist request for poddisruptionbudgets ended with an error, falling back to the standard LIST semantics, err = %v", err) + } + result, err := c.list(ctx, opts) + if err == nil { + consistencydetector.CheckListFromCacheDataConsistencyIfRequested(ctx, "list request for poddisruptionbudgets", c.list, opts, result) + } + return result, err } // list takes label and field selectors, and returns the list of PodDisruptionBudgets that match those selectors. @@ -110,6 +121,23 @@ func (c *podDisruptionBudgets) list(ctx context.Context, opts metav1.ListOptions return } +// watchList establishes a watch stream with the server and returns the list of PodDisruptionBudgets +func (c *podDisruptionBudgets) watchList(ctx context.Context, opts metav1.ListOptions) (result *v1.PodDisruptionBudgetList, err error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + result = &v1.PodDisruptionBudgetList{} + err = c.client.Get(). + Namespace(c.ns). + Resource("poddisruptionbudgets"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + WatchList(ctx). + Into(result) + return +} + // Watch returns a watch.Interface that watches the requested podDisruptionBudgets. func (c *podDisruptionBudgets) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { var timeout time.Duration diff --git a/staging/src/k8s.io/client-go/kubernetes/typed/policy/v1beta1/poddisruptionbudget.go b/staging/src/k8s.io/client-go/kubernetes/typed/policy/v1beta1/poddisruptionbudget.go index 86fa7a689d2..27e20786ab9 100644 --- a/staging/src/k8s.io/client-go/kubernetes/typed/policy/v1beta1/poddisruptionbudget.go +++ b/staging/src/k8s.io/client-go/kubernetes/typed/policy/v1beta1/poddisruptionbudget.go @@ -32,6 +32,8 @@ import ( scheme "k8s.io/client-go/kubernetes/scheme" rest "k8s.io/client-go/rest" consistencydetector "k8s.io/client-go/util/consistencydetector" + watchlist "k8s.io/client-go/util/watchlist" + "k8s.io/klog/v2" ) // PodDisruptionBudgetsGetter has a method to return a PodDisruptionBudgetInterface. @@ -84,13 +86,22 @@ func (c *podDisruptionBudgets) Get(ctx context.Context, name string, options v1. } // List takes label and field selectors, and returns the list of PodDisruptionBudgets that match those selectors. -func (c *podDisruptionBudgets) List(ctx context.Context, opts v1.ListOptions) (result *v1beta1.PodDisruptionBudgetList, err error) { - defer func() { +func (c *podDisruptionBudgets) List(ctx context.Context, opts v1.ListOptions) (*v1beta1.PodDisruptionBudgetList, error) { + if watchListOptions, hasWatchListOptionsPrepared, watchListOptionsErr := watchlist.PrepareWatchListOptionsFromListOptions(opts); watchListOptionsErr != nil { + klog.Warningf("Failed preparing watchlist options for poddisruptionbudgets, falling back to the standard LIST semantics, err = %v", watchListOptionsErr) + } else if hasWatchListOptionsPrepared { + result, err := c.watchList(ctx, watchListOptions) if err == nil { - consistencydetector.CheckListFromCacheDataConsistencyIfRequested(ctx, "list request for poddisruptionbudgets", c.list, opts, result) + consistencydetector.CheckWatchListFromCacheDataConsistencyIfRequested(ctx, "watchlist request for poddisruptionbudgets", c.list, opts, result) + return result, nil } - }() - return c.list(ctx, opts) + klog.Warningf("The watchlist request for poddisruptionbudgets ended with an error, falling back to the standard LIST semantics, err = %v", err) + } + result, err := c.list(ctx, opts) + if err == nil { + consistencydetector.CheckListFromCacheDataConsistencyIfRequested(ctx, "list request for poddisruptionbudgets", c.list, opts, result) + } + return result, err } // list takes label and field selectors, and returns the list of PodDisruptionBudgets that match those selectors. @@ -110,6 +121,23 @@ func (c *podDisruptionBudgets) list(ctx context.Context, opts v1.ListOptions) (r return } +// watchList establishes a watch stream with the server and returns the list of PodDisruptionBudgets +func (c *podDisruptionBudgets) watchList(ctx context.Context, opts v1.ListOptions) (result *v1beta1.PodDisruptionBudgetList, err error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + result = &v1beta1.PodDisruptionBudgetList{} + err = c.client.Get(). + Namespace(c.ns). + Resource("poddisruptionbudgets"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + WatchList(ctx). + Into(result) + return +} + // Watch returns a watch.Interface that watches the requested podDisruptionBudgets. func (c *podDisruptionBudgets) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { var timeout time.Duration diff --git a/staging/src/k8s.io/client-go/kubernetes/typed/rbac/v1/clusterrole.go b/staging/src/k8s.io/client-go/kubernetes/typed/rbac/v1/clusterrole.go index c072389a70d..6462a2d3dcc 100644 --- a/staging/src/k8s.io/client-go/kubernetes/typed/rbac/v1/clusterrole.go +++ b/staging/src/k8s.io/client-go/kubernetes/typed/rbac/v1/clusterrole.go @@ -32,6 +32,8 @@ import ( scheme "k8s.io/client-go/kubernetes/scheme" rest "k8s.io/client-go/rest" consistencydetector "k8s.io/client-go/util/consistencydetector" + watchlist "k8s.io/client-go/util/watchlist" + "k8s.io/klog/v2" ) // ClusterRolesGetter has a method to return a ClusterRoleInterface. @@ -79,13 +81,22 @@ func (c *clusterRoles) Get(ctx context.Context, name string, options metav1.GetO } // List takes label and field selectors, and returns the list of ClusterRoles that match those selectors. -func (c *clusterRoles) List(ctx context.Context, opts metav1.ListOptions) (result *v1.ClusterRoleList, err error) { - defer func() { +func (c *clusterRoles) List(ctx context.Context, opts metav1.ListOptions) (*v1.ClusterRoleList, error) { + if watchListOptions, hasWatchListOptionsPrepared, watchListOptionsErr := watchlist.PrepareWatchListOptionsFromListOptions(opts); watchListOptionsErr != nil { + klog.Warningf("Failed preparing watchlist options for clusterroles, falling back to the standard LIST semantics, err = %v", watchListOptionsErr) + } else if hasWatchListOptionsPrepared { + result, err := c.watchList(ctx, watchListOptions) if err == nil { - consistencydetector.CheckListFromCacheDataConsistencyIfRequested(ctx, "list request for clusterroles", c.list, opts, result) + consistencydetector.CheckWatchListFromCacheDataConsistencyIfRequested(ctx, "watchlist request for clusterroles", c.list, opts, result) + return result, nil } - }() - return c.list(ctx, opts) + klog.Warningf("The watchlist request for clusterroles ended with an error, falling back to the standard LIST semantics, err = %v", err) + } + result, err := c.list(ctx, opts) + if err == nil { + consistencydetector.CheckListFromCacheDataConsistencyIfRequested(ctx, "list request for clusterroles", c.list, opts, result) + } + return result, err } // list takes label and field selectors, and returns the list of ClusterRoles that match those selectors. @@ -104,6 +115,22 @@ func (c *clusterRoles) list(ctx context.Context, opts metav1.ListOptions) (resul return } +// watchList establishes a watch stream with the server and returns the list of ClusterRoles +func (c *clusterRoles) watchList(ctx context.Context, opts metav1.ListOptions) (result *v1.ClusterRoleList, err error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + result = &v1.ClusterRoleList{} + err = c.client.Get(). + Resource("clusterroles"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + WatchList(ctx). + Into(result) + return +} + // Watch returns a watch.Interface that watches the requested clusterRoles. func (c *clusterRoles) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { var timeout time.Duration diff --git a/staging/src/k8s.io/client-go/kubernetes/typed/rbac/v1/clusterrolebinding.go b/staging/src/k8s.io/client-go/kubernetes/typed/rbac/v1/clusterrolebinding.go index 09003ceb24e..e2f3d947787 100644 --- a/staging/src/k8s.io/client-go/kubernetes/typed/rbac/v1/clusterrolebinding.go +++ b/staging/src/k8s.io/client-go/kubernetes/typed/rbac/v1/clusterrolebinding.go @@ -32,6 +32,8 @@ import ( scheme "k8s.io/client-go/kubernetes/scheme" rest "k8s.io/client-go/rest" consistencydetector "k8s.io/client-go/util/consistencydetector" + watchlist "k8s.io/client-go/util/watchlist" + "k8s.io/klog/v2" ) // ClusterRoleBindingsGetter has a method to return a ClusterRoleBindingInterface. @@ -79,13 +81,22 @@ func (c *clusterRoleBindings) Get(ctx context.Context, name string, options meta } // List takes label and field selectors, and returns the list of ClusterRoleBindings that match those selectors. -func (c *clusterRoleBindings) List(ctx context.Context, opts metav1.ListOptions) (result *v1.ClusterRoleBindingList, err error) { - defer func() { +func (c *clusterRoleBindings) List(ctx context.Context, opts metav1.ListOptions) (*v1.ClusterRoleBindingList, error) { + if watchListOptions, hasWatchListOptionsPrepared, watchListOptionsErr := watchlist.PrepareWatchListOptionsFromListOptions(opts); watchListOptionsErr != nil { + klog.Warningf("Failed preparing watchlist options for clusterrolebindings, falling back to the standard LIST semantics, err = %v", watchListOptionsErr) + } else if hasWatchListOptionsPrepared { + result, err := c.watchList(ctx, watchListOptions) if err == nil { - consistencydetector.CheckListFromCacheDataConsistencyIfRequested(ctx, "list request for clusterrolebindings", c.list, opts, result) + consistencydetector.CheckWatchListFromCacheDataConsistencyIfRequested(ctx, "watchlist request for clusterrolebindings", c.list, opts, result) + return result, nil } - }() - return c.list(ctx, opts) + klog.Warningf("The watchlist request for clusterrolebindings ended with an error, falling back to the standard LIST semantics, err = %v", err) + } + result, err := c.list(ctx, opts) + if err == nil { + consistencydetector.CheckListFromCacheDataConsistencyIfRequested(ctx, "list request for clusterrolebindings", c.list, opts, result) + } + return result, err } // list takes label and field selectors, and returns the list of ClusterRoleBindings that match those selectors. @@ -104,6 +115,22 @@ func (c *clusterRoleBindings) list(ctx context.Context, opts metav1.ListOptions) return } +// watchList establishes a watch stream with the server and returns the list of ClusterRoleBindings +func (c *clusterRoleBindings) watchList(ctx context.Context, opts metav1.ListOptions) (result *v1.ClusterRoleBindingList, err error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + result = &v1.ClusterRoleBindingList{} + err = c.client.Get(). + Resource("clusterrolebindings"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + WatchList(ctx). + Into(result) + return +} + // Watch returns a watch.Interface that watches the requested clusterRoleBindings. func (c *clusterRoleBindings) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { var timeout time.Duration diff --git a/staging/src/k8s.io/client-go/kubernetes/typed/rbac/v1/role.go b/staging/src/k8s.io/client-go/kubernetes/typed/rbac/v1/role.go index fd2b92c0336..cac029866a7 100644 --- a/staging/src/k8s.io/client-go/kubernetes/typed/rbac/v1/role.go +++ b/staging/src/k8s.io/client-go/kubernetes/typed/rbac/v1/role.go @@ -32,6 +32,8 @@ import ( scheme "k8s.io/client-go/kubernetes/scheme" rest "k8s.io/client-go/rest" consistencydetector "k8s.io/client-go/util/consistencydetector" + watchlist "k8s.io/client-go/util/watchlist" + "k8s.io/klog/v2" ) // RolesGetter has a method to return a RoleInterface. @@ -82,13 +84,22 @@ func (c *roles) Get(ctx context.Context, name string, options metav1.GetOptions) } // List takes label and field selectors, and returns the list of Roles that match those selectors. -func (c *roles) List(ctx context.Context, opts metav1.ListOptions) (result *v1.RoleList, err error) { - defer func() { +func (c *roles) List(ctx context.Context, opts metav1.ListOptions) (*v1.RoleList, error) { + if watchListOptions, hasWatchListOptionsPrepared, watchListOptionsErr := watchlist.PrepareWatchListOptionsFromListOptions(opts); watchListOptionsErr != nil { + klog.Warningf("Failed preparing watchlist options for roles, falling back to the standard LIST semantics, err = %v", watchListOptionsErr) + } else if hasWatchListOptionsPrepared { + result, err := c.watchList(ctx, watchListOptions) if err == nil { - consistencydetector.CheckListFromCacheDataConsistencyIfRequested(ctx, "list request for roles", c.list, opts, result) + consistencydetector.CheckWatchListFromCacheDataConsistencyIfRequested(ctx, "watchlist request for roles", c.list, opts, result) + return result, nil } - }() - return c.list(ctx, opts) + klog.Warningf("The watchlist request for roles ended with an error, falling back to the standard LIST semantics, err = %v", err) + } + result, err := c.list(ctx, opts) + if err == nil { + consistencydetector.CheckListFromCacheDataConsistencyIfRequested(ctx, "list request for roles", c.list, opts, result) + } + return result, err } // list takes label and field selectors, and returns the list of Roles that match those selectors. @@ -108,6 +119,23 @@ func (c *roles) list(ctx context.Context, opts metav1.ListOptions) (result *v1.R return } +// watchList establishes a watch stream with the server and returns the list of Roles +func (c *roles) watchList(ctx context.Context, opts metav1.ListOptions) (result *v1.RoleList, err error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + result = &v1.RoleList{} + err = c.client.Get(). + Namespace(c.ns). + Resource("roles"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + WatchList(ctx). + Into(result) + return +} + // Watch returns a watch.Interface that watches the requested roles. func (c *roles) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { var timeout time.Duration diff --git a/staging/src/k8s.io/client-go/kubernetes/typed/rbac/v1/rolebinding.go b/staging/src/k8s.io/client-go/kubernetes/typed/rbac/v1/rolebinding.go index 567c4b51c7c..2cbead33a56 100644 --- a/staging/src/k8s.io/client-go/kubernetes/typed/rbac/v1/rolebinding.go +++ b/staging/src/k8s.io/client-go/kubernetes/typed/rbac/v1/rolebinding.go @@ -32,6 +32,8 @@ import ( scheme "k8s.io/client-go/kubernetes/scheme" rest "k8s.io/client-go/rest" consistencydetector "k8s.io/client-go/util/consistencydetector" + watchlist "k8s.io/client-go/util/watchlist" + "k8s.io/klog/v2" ) // RoleBindingsGetter has a method to return a RoleBindingInterface. @@ -82,13 +84,22 @@ func (c *roleBindings) Get(ctx context.Context, name string, options metav1.GetO } // List takes label and field selectors, and returns the list of RoleBindings that match those selectors. -func (c *roleBindings) List(ctx context.Context, opts metav1.ListOptions) (result *v1.RoleBindingList, err error) { - defer func() { +func (c *roleBindings) List(ctx context.Context, opts metav1.ListOptions) (*v1.RoleBindingList, error) { + if watchListOptions, hasWatchListOptionsPrepared, watchListOptionsErr := watchlist.PrepareWatchListOptionsFromListOptions(opts); watchListOptionsErr != nil { + klog.Warningf("Failed preparing watchlist options for rolebindings, falling back to the standard LIST semantics, err = %v", watchListOptionsErr) + } else if hasWatchListOptionsPrepared { + result, err := c.watchList(ctx, watchListOptions) if err == nil { - consistencydetector.CheckListFromCacheDataConsistencyIfRequested(ctx, "list request for rolebindings", c.list, opts, result) + consistencydetector.CheckWatchListFromCacheDataConsistencyIfRequested(ctx, "watchlist request for rolebindings", c.list, opts, result) + return result, nil } - }() - return c.list(ctx, opts) + klog.Warningf("The watchlist request for rolebindings ended with an error, falling back to the standard LIST semantics, err = %v", err) + } + result, err := c.list(ctx, opts) + if err == nil { + consistencydetector.CheckListFromCacheDataConsistencyIfRequested(ctx, "list request for rolebindings", c.list, opts, result) + } + return result, err } // list takes label and field selectors, and returns the list of RoleBindings that match those selectors. @@ -108,6 +119,23 @@ func (c *roleBindings) list(ctx context.Context, opts metav1.ListOptions) (resul return } +// watchList establishes a watch stream with the server and returns the list of RoleBindings +func (c *roleBindings) watchList(ctx context.Context, opts metav1.ListOptions) (result *v1.RoleBindingList, err error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + result = &v1.RoleBindingList{} + err = c.client.Get(). + Namespace(c.ns). + Resource("rolebindings"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + WatchList(ctx). + Into(result) + return +} + // Watch returns a watch.Interface that watches the requested roleBindings. func (c *roleBindings) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { var timeout time.Duration diff --git a/staging/src/k8s.io/client-go/kubernetes/typed/rbac/v1alpha1/clusterrole.go b/staging/src/k8s.io/client-go/kubernetes/typed/rbac/v1alpha1/clusterrole.go index b8021be3ad6..f22b5b3e35e 100644 --- a/staging/src/k8s.io/client-go/kubernetes/typed/rbac/v1alpha1/clusterrole.go +++ b/staging/src/k8s.io/client-go/kubernetes/typed/rbac/v1alpha1/clusterrole.go @@ -32,6 +32,8 @@ import ( scheme "k8s.io/client-go/kubernetes/scheme" rest "k8s.io/client-go/rest" consistencydetector "k8s.io/client-go/util/consistencydetector" + watchlist "k8s.io/client-go/util/watchlist" + "k8s.io/klog/v2" ) // ClusterRolesGetter has a method to return a ClusterRoleInterface. @@ -79,13 +81,22 @@ func (c *clusterRoles) Get(ctx context.Context, name string, options v1.GetOptio } // List takes label and field selectors, and returns the list of ClusterRoles that match those selectors. -func (c *clusterRoles) List(ctx context.Context, opts v1.ListOptions) (result *v1alpha1.ClusterRoleList, err error) { - defer func() { +func (c *clusterRoles) List(ctx context.Context, opts v1.ListOptions) (*v1alpha1.ClusterRoleList, error) { + if watchListOptions, hasWatchListOptionsPrepared, watchListOptionsErr := watchlist.PrepareWatchListOptionsFromListOptions(opts); watchListOptionsErr != nil { + klog.Warningf("Failed preparing watchlist options for clusterroles, falling back to the standard LIST semantics, err = %v", watchListOptionsErr) + } else if hasWatchListOptionsPrepared { + result, err := c.watchList(ctx, watchListOptions) if err == nil { - consistencydetector.CheckListFromCacheDataConsistencyIfRequested(ctx, "list request for clusterroles", c.list, opts, result) + consistencydetector.CheckWatchListFromCacheDataConsistencyIfRequested(ctx, "watchlist request for clusterroles", c.list, opts, result) + return result, nil } - }() - return c.list(ctx, opts) + klog.Warningf("The watchlist request for clusterroles ended with an error, falling back to the standard LIST semantics, err = %v", err) + } + result, err := c.list(ctx, opts) + if err == nil { + consistencydetector.CheckListFromCacheDataConsistencyIfRequested(ctx, "list request for clusterroles", c.list, opts, result) + } + return result, err } // list takes label and field selectors, and returns the list of ClusterRoles that match those selectors. @@ -104,6 +115,22 @@ func (c *clusterRoles) list(ctx context.Context, opts v1.ListOptions) (result *v return } +// watchList establishes a watch stream with the server and returns the list of ClusterRoles +func (c *clusterRoles) watchList(ctx context.Context, opts v1.ListOptions) (result *v1alpha1.ClusterRoleList, err error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + result = &v1alpha1.ClusterRoleList{} + err = c.client.Get(). + Resource("clusterroles"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + WatchList(ctx). + Into(result) + return +} + // Watch returns a watch.Interface that watches the requested clusterRoles. func (c *clusterRoles) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { var timeout time.Duration diff --git a/staging/src/k8s.io/client-go/kubernetes/typed/rbac/v1alpha1/clusterrolebinding.go b/staging/src/k8s.io/client-go/kubernetes/typed/rbac/v1alpha1/clusterrolebinding.go index f55f7db39cb..f3ef5679135 100644 --- a/staging/src/k8s.io/client-go/kubernetes/typed/rbac/v1alpha1/clusterrolebinding.go +++ b/staging/src/k8s.io/client-go/kubernetes/typed/rbac/v1alpha1/clusterrolebinding.go @@ -32,6 +32,8 @@ import ( scheme "k8s.io/client-go/kubernetes/scheme" rest "k8s.io/client-go/rest" consistencydetector "k8s.io/client-go/util/consistencydetector" + watchlist "k8s.io/client-go/util/watchlist" + "k8s.io/klog/v2" ) // ClusterRoleBindingsGetter has a method to return a ClusterRoleBindingInterface. @@ -79,13 +81,22 @@ func (c *clusterRoleBindings) Get(ctx context.Context, name string, options v1.G } // List takes label and field selectors, and returns the list of ClusterRoleBindings that match those selectors. -func (c *clusterRoleBindings) List(ctx context.Context, opts v1.ListOptions) (result *v1alpha1.ClusterRoleBindingList, err error) { - defer func() { +func (c *clusterRoleBindings) List(ctx context.Context, opts v1.ListOptions) (*v1alpha1.ClusterRoleBindingList, error) { + if watchListOptions, hasWatchListOptionsPrepared, watchListOptionsErr := watchlist.PrepareWatchListOptionsFromListOptions(opts); watchListOptionsErr != nil { + klog.Warningf("Failed preparing watchlist options for clusterrolebindings, falling back to the standard LIST semantics, err = %v", watchListOptionsErr) + } else if hasWatchListOptionsPrepared { + result, err := c.watchList(ctx, watchListOptions) if err == nil { - consistencydetector.CheckListFromCacheDataConsistencyIfRequested(ctx, "list request for clusterrolebindings", c.list, opts, result) + consistencydetector.CheckWatchListFromCacheDataConsistencyIfRequested(ctx, "watchlist request for clusterrolebindings", c.list, opts, result) + return result, nil } - }() - return c.list(ctx, opts) + klog.Warningf("The watchlist request for clusterrolebindings ended with an error, falling back to the standard LIST semantics, err = %v", err) + } + result, err := c.list(ctx, opts) + if err == nil { + consistencydetector.CheckListFromCacheDataConsistencyIfRequested(ctx, "list request for clusterrolebindings", c.list, opts, result) + } + return result, err } // list takes label and field selectors, and returns the list of ClusterRoleBindings that match those selectors. @@ -104,6 +115,22 @@ func (c *clusterRoleBindings) list(ctx context.Context, opts v1.ListOptions) (re return } +// watchList establishes a watch stream with the server and returns the list of ClusterRoleBindings +func (c *clusterRoleBindings) watchList(ctx context.Context, opts v1.ListOptions) (result *v1alpha1.ClusterRoleBindingList, err error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + result = &v1alpha1.ClusterRoleBindingList{} + err = c.client.Get(). + Resource("clusterrolebindings"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + WatchList(ctx). + Into(result) + return +} + // Watch returns a watch.Interface that watches the requested clusterRoleBindings. func (c *clusterRoleBindings) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { var timeout time.Duration diff --git a/staging/src/k8s.io/client-go/kubernetes/typed/rbac/v1alpha1/role.go b/staging/src/k8s.io/client-go/kubernetes/typed/rbac/v1alpha1/role.go index babc5d245dc..13f4b80af70 100644 --- a/staging/src/k8s.io/client-go/kubernetes/typed/rbac/v1alpha1/role.go +++ b/staging/src/k8s.io/client-go/kubernetes/typed/rbac/v1alpha1/role.go @@ -32,6 +32,8 @@ import ( scheme "k8s.io/client-go/kubernetes/scheme" rest "k8s.io/client-go/rest" consistencydetector "k8s.io/client-go/util/consistencydetector" + watchlist "k8s.io/client-go/util/watchlist" + "k8s.io/klog/v2" ) // RolesGetter has a method to return a RoleInterface. @@ -82,13 +84,22 @@ func (c *roles) Get(ctx context.Context, name string, options v1.GetOptions) (re } // List takes label and field selectors, and returns the list of Roles that match those selectors. -func (c *roles) List(ctx context.Context, opts v1.ListOptions) (result *v1alpha1.RoleList, err error) { - defer func() { +func (c *roles) List(ctx context.Context, opts v1.ListOptions) (*v1alpha1.RoleList, error) { + if watchListOptions, hasWatchListOptionsPrepared, watchListOptionsErr := watchlist.PrepareWatchListOptionsFromListOptions(opts); watchListOptionsErr != nil { + klog.Warningf("Failed preparing watchlist options for roles, falling back to the standard LIST semantics, err = %v", watchListOptionsErr) + } else if hasWatchListOptionsPrepared { + result, err := c.watchList(ctx, watchListOptions) if err == nil { - consistencydetector.CheckListFromCacheDataConsistencyIfRequested(ctx, "list request for roles", c.list, opts, result) + consistencydetector.CheckWatchListFromCacheDataConsistencyIfRequested(ctx, "watchlist request for roles", c.list, opts, result) + return result, nil } - }() - return c.list(ctx, opts) + klog.Warningf("The watchlist request for roles ended with an error, falling back to the standard LIST semantics, err = %v", err) + } + result, err := c.list(ctx, opts) + if err == nil { + consistencydetector.CheckListFromCacheDataConsistencyIfRequested(ctx, "list request for roles", c.list, opts, result) + } + return result, err } // list takes label and field selectors, and returns the list of Roles that match those selectors. @@ -108,6 +119,23 @@ func (c *roles) list(ctx context.Context, opts v1.ListOptions) (result *v1alpha1 return } +// watchList establishes a watch stream with the server and returns the list of Roles +func (c *roles) watchList(ctx context.Context, opts v1.ListOptions) (result *v1alpha1.RoleList, err error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + result = &v1alpha1.RoleList{} + err = c.client.Get(). + Namespace(c.ns). + Resource("roles"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + WatchList(ctx). + Into(result) + return +} + // Watch returns a watch.Interface that watches the requested roles. func (c *roles) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { var timeout time.Duration diff --git a/staging/src/k8s.io/client-go/kubernetes/typed/rbac/v1alpha1/rolebinding.go b/staging/src/k8s.io/client-go/kubernetes/typed/rbac/v1alpha1/rolebinding.go index 1804457ea30..30285ccaf2a 100644 --- a/staging/src/k8s.io/client-go/kubernetes/typed/rbac/v1alpha1/rolebinding.go +++ b/staging/src/k8s.io/client-go/kubernetes/typed/rbac/v1alpha1/rolebinding.go @@ -32,6 +32,8 @@ import ( scheme "k8s.io/client-go/kubernetes/scheme" rest "k8s.io/client-go/rest" consistencydetector "k8s.io/client-go/util/consistencydetector" + watchlist "k8s.io/client-go/util/watchlist" + "k8s.io/klog/v2" ) // RoleBindingsGetter has a method to return a RoleBindingInterface. @@ -82,13 +84,22 @@ func (c *roleBindings) Get(ctx context.Context, name string, options v1.GetOptio } // List takes label and field selectors, and returns the list of RoleBindings that match those selectors. -func (c *roleBindings) List(ctx context.Context, opts v1.ListOptions) (result *v1alpha1.RoleBindingList, err error) { - defer func() { +func (c *roleBindings) List(ctx context.Context, opts v1.ListOptions) (*v1alpha1.RoleBindingList, error) { + if watchListOptions, hasWatchListOptionsPrepared, watchListOptionsErr := watchlist.PrepareWatchListOptionsFromListOptions(opts); watchListOptionsErr != nil { + klog.Warningf("Failed preparing watchlist options for rolebindings, falling back to the standard LIST semantics, err = %v", watchListOptionsErr) + } else if hasWatchListOptionsPrepared { + result, err := c.watchList(ctx, watchListOptions) if err == nil { - consistencydetector.CheckListFromCacheDataConsistencyIfRequested(ctx, "list request for rolebindings", c.list, opts, result) + consistencydetector.CheckWatchListFromCacheDataConsistencyIfRequested(ctx, "watchlist request for rolebindings", c.list, opts, result) + return result, nil } - }() - return c.list(ctx, opts) + klog.Warningf("The watchlist request for rolebindings ended with an error, falling back to the standard LIST semantics, err = %v", err) + } + result, err := c.list(ctx, opts) + if err == nil { + consistencydetector.CheckListFromCacheDataConsistencyIfRequested(ctx, "list request for rolebindings", c.list, opts, result) + } + return result, err } // list takes label and field selectors, and returns the list of RoleBindings that match those selectors. @@ -108,6 +119,23 @@ func (c *roleBindings) list(ctx context.Context, opts v1.ListOptions) (result *v return } +// watchList establishes a watch stream with the server and returns the list of RoleBindings +func (c *roleBindings) watchList(ctx context.Context, opts v1.ListOptions) (result *v1alpha1.RoleBindingList, err error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + result = &v1alpha1.RoleBindingList{} + err = c.client.Get(). + Namespace(c.ns). + Resource("rolebindings"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + WatchList(ctx). + Into(result) + return +} + // Watch returns a watch.Interface that watches the requested roleBindings. func (c *roleBindings) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { var timeout time.Duration diff --git a/staging/src/k8s.io/client-go/kubernetes/typed/rbac/v1beta1/clusterrole.go b/staging/src/k8s.io/client-go/kubernetes/typed/rbac/v1beta1/clusterrole.go index e61f4ce3753..3df9c1c65e3 100644 --- a/staging/src/k8s.io/client-go/kubernetes/typed/rbac/v1beta1/clusterrole.go +++ b/staging/src/k8s.io/client-go/kubernetes/typed/rbac/v1beta1/clusterrole.go @@ -32,6 +32,8 @@ import ( scheme "k8s.io/client-go/kubernetes/scheme" rest "k8s.io/client-go/rest" consistencydetector "k8s.io/client-go/util/consistencydetector" + watchlist "k8s.io/client-go/util/watchlist" + "k8s.io/klog/v2" ) // ClusterRolesGetter has a method to return a ClusterRoleInterface. @@ -79,13 +81,22 @@ func (c *clusterRoles) Get(ctx context.Context, name string, options v1.GetOptio } // List takes label and field selectors, and returns the list of ClusterRoles that match those selectors. -func (c *clusterRoles) List(ctx context.Context, opts v1.ListOptions) (result *v1beta1.ClusterRoleList, err error) { - defer func() { +func (c *clusterRoles) List(ctx context.Context, opts v1.ListOptions) (*v1beta1.ClusterRoleList, error) { + if watchListOptions, hasWatchListOptionsPrepared, watchListOptionsErr := watchlist.PrepareWatchListOptionsFromListOptions(opts); watchListOptionsErr != nil { + klog.Warningf("Failed preparing watchlist options for clusterroles, falling back to the standard LIST semantics, err = %v", watchListOptionsErr) + } else if hasWatchListOptionsPrepared { + result, err := c.watchList(ctx, watchListOptions) if err == nil { - consistencydetector.CheckListFromCacheDataConsistencyIfRequested(ctx, "list request for clusterroles", c.list, opts, result) + consistencydetector.CheckWatchListFromCacheDataConsistencyIfRequested(ctx, "watchlist request for clusterroles", c.list, opts, result) + return result, nil } - }() - return c.list(ctx, opts) + klog.Warningf("The watchlist request for clusterroles ended with an error, falling back to the standard LIST semantics, err = %v", err) + } + result, err := c.list(ctx, opts) + if err == nil { + consistencydetector.CheckListFromCacheDataConsistencyIfRequested(ctx, "list request for clusterroles", c.list, opts, result) + } + return result, err } // list takes label and field selectors, and returns the list of ClusterRoles that match those selectors. @@ -104,6 +115,22 @@ func (c *clusterRoles) list(ctx context.Context, opts v1.ListOptions) (result *v return } +// watchList establishes a watch stream with the server and returns the list of ClusterRoles +func (c *clusterRoles) watchList(ctx context.Context, opts v1.ListOptions) (result *v1beta1.ClusterRoleList, err error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + result = &v1beta1.ClusterRoleList{} + err = c.client.Get(). + Resource("clusterroles"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + WatchList(ctx). + Into(result) + return +} + // Watch returns a watch.Interface that watches the requested clusterRoles. func (c *clusterRoles) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { var timeout time.Duration diff --git a/staging/src/k8s.io/client-go/kubernetes/typed/rbac/v1beta1/clusterrolebinding.go b/staging/src/k8s.io/client-go/kubernetes/typed/rbac/v1beta1/clusterrolebinding.go index a80e99be31f..0820a7bcdf3 100644 --- a/staging/src/k8s.io/client-go/kubernetes/typed/rbac/v1beta1/clusterrolebinding.go +++ b/staging/src/k8s.io/client-go/kubernetes/typed/rbac/v1beta1/clusterrolebinding.go @@ -32,6 +32,8 @@ import ( scheme "k8s.io/client-go/kubernetes/scheme" rest "k8s.io/client-go/rest" consistencydetector "k8s.io/client-go/util/consistencydetector" + watchlist "k8s.io/client-go/util/watchlist" + "k8s.io/klog/v2" ) // ClusterRoleBindingsGetter has a method to return a ClusterRoleBindingInterface. @@ -79,13 +81,22 @@ func (c *clusterRoleBindings) Get(ctx context.Context, name string, options v1.G } // List takes label and field selectors, and returns the list of ClusterRoleBindings that match those selectors. -func (c *clusterRoleBindings) List(ctx context.Context, opts v1.ListOptions) (result *v1beta1.ClusterRoleBindingList, err error) { - defer func() { +func (c *clusterRoleBindings) List(ctx context.Context, opts v1.ListOptions) (*v1beta1.ClusterRoleBindingList, error) { + if watchListOptions, hasWatchListOptionsPrepared, watchListOptionsErr := watchlist.PrepareWatchListOptionsFromListOptions(opts); watchListOptionsErr != nil { + klog.Warningf("Failed preparing watchlist options for clusterrolebindings, falling back to the standard LIST semantics, err = %v", watchListOptionsErr) + } else if hasWatchListOptionsPrepared { + result, err := c.watchList(ctx, watchListOptions) if err == nil { - consistencydetector.CheckListFromCacheDataConsistencyIfRequested(ctx, "list request for clusterrolebindings", c.list, opts, result) + consistencydetector.CheckWatchListFromCacheDataConsistencyIfRequested(ctx, "watchlist request for clusterrolebindings", c.list, opts, result) + return result, nil } - }() - return c.list(ctx, opts) + klog.Warningf("The watchlist request for clusterrolebindings ended with an error, falling back to the standard LIST semantics, err = %v", err) + } + result, err := c.list(ctx, opts) + if err == nil { + consistencydetector.CheckListFromCacheDataConsistencyIfRequested(ctx, "list request for clusterrolebindings", c.list, opts, result) + } + return result, err } // list takes label and field selectors, and returns the list of ClusterRoleBindings that match those selectors. @@ -104,6 +115,22 @@ func (c *clusterRoleBindings) list(ctx context.Context, opts v1.ListOptions) (re return } +// watchList establishes a watch stream with the server and returns the list of ClusterRoleBindings +func (c *clusterRoleBindings) watchList(ctx context.Context, opts v1.ListOptions) (result *v1beta1.ClusterRoleBindingList, err error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + result = &v1beta1.ClusterRoleBindingList{} + err = c.client.Get(). + Resource("clusterrolebindings"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + WatchList(ctx). + Into(result) + return +} + // Watch returns a watch.Interface that watches the requested clusterRoleBindings. func (c *clusterRoleBindings) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { var timeout time.Duration diff --git a/staging/src/k8s.io/client-go/kubernetes/typed/rbac/v1beta1/role.go b/staging/src/k8s.io/client-go/kubernetes/typed/rbac/v1beta1/role.go index 2dbb713d540..a2e9cbb97a1 100644 --- a/staging/src/k8s.io/client-go/kubernetes/typed/rbac/v1beta1/role.go +++ b/staging/src/k8s.io/client-go/kubernetes/typed/rbac/v1beta1/role.go @@ -32,6 +32,8 @@ import ( scheme "k8s.io/client-go/kubernetes/scheme" rest "k8s.io/client-go/rest" consistencydetector "k8s.io/client-go/util/consistencydetector" + watchlist "k8s.io/client-go/util/watchlist" + "k8s.io/klog/v2" ) // RolesGetter has a method to return a RoleInterface. @@ -82,13 +84,22 @@ func (c *roles) Get(ctx context.Context, name string, options v1.GetOptions) (re } // List takes label and field selectors, and returns the list of Roles that match those selectors. -func (c *roles) List(ctx context.Context, opts v1.ListOptions) (result *v1beta1.RoleList, err error) { - defer func() { +func (c *roles) List(ctx context.Context, opts v1.ListOptions) (*v1beta1.RoleList, error) { + if watchListOptions, hasWatchListOptionsPrepared, watchListOptionsErr := watchlist.PrepareWatchListOptionsFromListOptions(opts); watchListOptionsErr != nil { + klog.Warningf("Failed preparing watchlist options for roles, falling back to the standard LIST semantics, err = %v", watchListOptionsErr) + } else if hasWatchListOptionsPrepared { + result, err := c.watchList(ctx, watchListOptions) if err == nil { - consistencydetector.CheckListFromCacheDataConsistencyIfRequested(ctx, "list request for roles", c.list, opts, result) + consistencydetector.CheckWatchListFromCacheDataConsistencyIfRequested(ctx, "watchlist request for roles", c.list, opts, result) + return result, nil } - }() - return c.list(ctx, opts) + klog.Warningf("The watchlist request for roles ended with an error, falling back to the standard LIST semantics, err = %v", err) + } + result, err := c.list(ctx, opts) + if err == nil { + consistencydetector.CheckListFromCacheDataConsistencyIfRequested(ctx, "list request for roles", c.list, opts, result) + } + return result, err } // list takes label and field selectors, and returns the list of Roles that match those selectors. @@ -108,6 +119,23 @@ func (c *roles) list(ctx context.Context, opts v1.ListOptions) (result *v1beta1. return } +// watchList establishes a watch stream with the server and returns the list of Roles +func (c *roles) watchList(ctx context.Context, opts v1.ListOptions) (result *v1beta1.RoleList, err error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + result = &v1beta1.RoleList{} + err = c.client.Get(). + Namespace(c.ns). + Resource("roles"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + WatchList(ctx). + Into(result) + return +} + // Watch returns a watch.Interface that watches the requested roles. func (c *roles) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { var timeout time.Duration diff --git a/staging/src/k8s.io/client-go/kubernetes/typed/rbac/v1beta1/rolebinding.go b/staging/src/k8s.io/client-go/kubernetes/typed/rbac/v1beta1/rolebinding.go index dfb60abc446..f44cc4a6c68 100644 --- a/staging/src/k8s.io/client-go/kubernetes/typed/rbac/v1beta1/rolebinding.go +++ b/staging/src/k8s.io/client-go/kubernetes/typed/rbac/v1beta1/rolebinding.go @@ -32,6 +32,8 @@ import ( scheme "k8s.io/client-go/kubernetes/scheme" rest "k8s.io/client-go/rest" consistencydetector "k8s.io/client-go/util/consistencydetector" + watchlist "k8s.io/client-go/util/watchlist" + "k8s.io/klog/v2" ) // RoleBindingsGetter has a method to return a RoleBindingInterface. @@ -82,13 +84,22 @@ func (c *roleBindings) Get(ctx context.Context, name string, options v1.GetOptio } // List takes label and field selectors, and returns the list of RoleBindings that match those selectors. -func (c *roleBindings) List(ctx context.Context, opts v1.ListOptions) (result *v1beta1.RoleBindingList, err error) { - defer func() { +func (c *roleBindings) List(ctx context.Context, opts v1.ListOptions) (*v1beta1.RoleBindingList, error) { + if watchListOptions, hasWatchListOptionsPrepared, watchListOptionsErr := watchlist.PrepareWatchListOptionsFromListOptions(opts); watchListOptionsErr != nil { + klog.Warningf("Failed preparing watchlist options for rolebindings, falling back to the standard LIST semantics, err = %v", watchListOptionsErr) + } else if hasWatchListOptionsPrepared { + result, err := c.watchList(ctx, watchListOptions) if err == nil { - consistencydetector.CheckListFromCacheDataConsistencyIfRequested(ctx, "list request for rolebindings", c.list, opts, result) + consistencydetector.CheckWatchListFromCacheDataConsistencyIfRequested(ctx, "watchlist request for rolebindings", c.list, opts, result) + return result, nil } - }() - return c.list(ctx, opts) + klog.Warningf("The watchlist request for rolebindings ended with an error, falling back to the standard LIST semantics, err = %v", err) + } + result, err := c.list(ctx, opts) + if err == nil { + consistencydetector.CheckListFromCacheDataConsistencyIfRequested(ctx, "list request for rolebindings", c.list, opts, result) + } + return result, err } // list takes label and field selectors, and returns the list of RoleBindings that match those selectors. @@ -108,6 +119,23 @@ func (c *roleBindings) list(ctx context.Context, opts v1.ListOptions) (result *v return } +// watchList establishes a watch stream with the server and returns the list of RoleBindings +func (c *roleBindings) watchList(ctx context.Context, opts v1.ListOptions) (result *v1beta1.RoleBindingList, err error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + result = &v1beta1.RoleBindingList{} + err = c.client.Get(). + Namespace(c.ns). + Resource("rolebindings"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + WatchList(ctx). + Into(result) + return +} + // Watch returns a watch.Interface that watches the requested roleBindings. func (c *roleBindings) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { var timeout time.Duration diff --git a/staging/src/k8s.io/client-go/kubernetes/typed/resource/v1alpha2/podschedulingcontext.go b/staging/src/k8s.io/client-go/kubernetes/typed/resource/v1alpha2/podschedulingcontext.go index f5158bb63dc..260d4318fe2 100644 --- a/staging/src/k8s.io/client-go/kubernetes/typed/resource/v1alpha2/podschedulingcontext.go +++ b/staging/src/k8s.io/client-go/kubernetes/typed/resource/v1alpha2/podschedulingcontext.go @@ -32,6 +32,8 @@ import ( scheme "k8s.io/client-go/kubernetes/scheme" rest "k8s.io/client-go/rest" consistencydetector "k8s.io/client-go/util/consistencydetector" + watchlist "k8s.io/client-go/util/watchlist" + "k8s.io/klog/v2" ) // PodSchedulingContextsGetter has a method to return a PodSchedulingContextInterface. @@ -84,13 +86,22 @@ func (c *podSchedulingContexts) Get(ctx context.Context, name string, options v1 } // List takes label and field selectors, and returns the list of PodSchedulingContexts that match those selectors. -func (c *podSchedulingContexts) List(ctx context.Context, opts v1.ListOptions) (result *v1alpha2.PodSchedulingContextList, err error) { - defer func() { +func (c *podSchedulingContexts) List(ctx context.Context, opts v1.ListOptions) (*v1alpha2.PodSchedulingContextList, error) { + if watchListOptions, hasWatchListOptionsPrepared, watchListOptionsErr := watchlist.PrepareWatchListOptionsFromListOptions(opts); watchListOptionsErr != nil { + klog.Warningf("Failed preparing watchlist options for podschedulingcontexts, falling back to the standard LIST semantics, err = %v", watchListOptionsErr) + } else if hasWatchListOptionsPrepared { + result, err := c.watchList(ctx, watchListOptions) if err == nil { - consistencydetector.CheckListFromCacheDataConsistencyIfRequested(ctx, "list request for podschedulingcontexts", c.list, opts, result) + consistencydetector.CheckWatchListFromCacheDataConsistencyIfRequested(ctx, "watchlist request for podschedulingcontexts", c.list, opts, result) + return result, nil } - }() - return c.list(ctx, opts) + klog.Warningf("The watchlist request for podschedulingcontexts ended with an error, falling back to the standard LIST semantics, err = %v", err) + } + result, err := c.list(ctx, opts) + if err == nil { + consistencydetector.CheckListFromCacheDataConsistencyIfRequested(ctx, "list request for podschedulingcontexts", c.list, opts, result) + } + return result, err } // list takes label and field selectors, and returns the list of PodSchedulingContexts that match those selectors. @@ -110,6 +121,23 @@ func (c *podSchedulingContexts) list(ctx context.Context, opts v1.ListOptions) ( return } +// watchList establishes a watch stream with the server and returns the list of PodSchedulingContexts +func (c *podSchedulingContexts) watchList(ctx context.Context, opts v1.ListOptions) (result *v1alpha2.PodSchedulingContextList, err error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + result = &v1alpha2.PodSchedulingContextList{} + err = c.client.Get(). + Namespace(c.ns). + Resource("podschedulingcontexts"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + WatchList(ctx). + Into(result) + return +} + // Watch returns a watch.Interface that watches the requested podSchedulingContexts. func (c *podSchedulingContexts) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { var timeout time.Duration diff --git a/staging/src/k8s.io/client-go/kubernetes/typed/resource/v1alpha2/resourceclaim.go b/staging/src/k8s.io/client-go/kubernetes/typed/resource/v1alpha2/resourceclaim.go index bd1e574f467..4fb2de3dc06 100644 --- a/staging/src/k8s.io/client-go/kubernetes/typed/resource/v1alpha2/resourceclaim.go +++ b/staging/src/k8s.io/client-go/kubernetes/typed/resource/v1alpha2/resourceclaim.go @@ -32,6 +32,8 @@ import ( scheme "k8s.io/client-go/kubernetes/scheme" rest "k8s.io/client-go/rest" consistencydetector "k8s.io/client-go/util/consistencydetector" + watchlist "k8s.io/client-go/util/watchlist" + "k8s.io/klog/v2" ) // ResourceClaimsGetter has a method to return a ResourceClaimInterface. @@ -84,13 +86,22 @@ func (c *resourceClaims) Get(ctx context.Context, name string, options v1.GetOpt } // List takes label and field selectors, and returns the list of ResourceClaims that match those selectors. -func (c *resourceClaims) List(ctx context.Context, opts v1.ListOptions) (result *v1alpha2.ResourceClaimList, err error) { - defer func() { +func (c *resourceClaims) List(ctx context.Context, opts v1.ListOptions) (*v1alpha2.ResourceClaimList, error) { + if watchListOptions, hasWatchListOptionsPrepared, watchListOptionsErr := watchlist.PrepareWatchListOptionsFromListOptions(opts); watchListOptionsErr != nil { + klog.Warningf("Failed preparing watchlist options for resourceclaims, falling back to the standard LIST semantics, err = %v", watchListOptionsErr) + } else if hasWatchListOptionsPrepared { + result, err := c.watchList(ctx, watchListOptions) if err == nil { - consistencydetector.CheckListFromCacheDataConsistencyIfRequested(ctx, "list request for resourceclaims", c.list, opts, result) + consistencydetector.CheckWatchListFromCacheDataConsistencyIfRequested(ctx, "watchlist request for resourceclaims", c.list, opts, result) + return result, nil } - }() - return c.list(ctx, opts) + klog.Warningf("The watchlist request for resourceclaims ended with an error, falling back to the standard LIST semantics, err = %v", err) + } + result, err := c.list(ctx, opts) + if err == nil { + consistencydetector.CheckListFromCacheDataConsistencyIfRequested(ctx, "list request for resourceclaims", c.list, opts, result) + } + return result, err } // list takes label and field selectors, and returns the list of ResourceClaims that match those selectors. @@ -110,6 +121,23 @@ func (c *resourceClaims) list(ctx context.Context, opts v1.ListOptions) (result return } +// watchList establishes a watch stream with the server and returns the list of ResourceClaims +func (c *resourceClaims) watchList(ctx context.Context, opts v1.ListOptions) (result *v1alpha2.ResourceClaimList, err error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + result = &v1alpha2.ResourceClaimList{} + err = c.client.Get(). + Namespace(c.ns). + Resource("resourceclaims"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + WatchList(ctx). + Into(result) + return +} + // Watch returns a watch.Interface that watches the requested resourceClaims. func (c *resourceClaims) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { var timeout time.Duration diff --git a/staging/src/k8s.io/client-go/kubernetes/typed/resource/v1alpha2/resourceclaimparameters.go b/staging/src/k8s.io/client-go/kubernetes/typed/resource/v1alpha2/resourceclaimparameters.go index 4f37f1672b3..c1a733e17f2 100644 --- a/staging/src/k8s.io/client-go/kubernetes/typed/resource/v1alpha2/resourceclaimparameters.go +++ b/staging/src/k8s.io/client-go/kubernetes/typed/resource/v1alpha2/resourceclaimparameters.go @@ -32,6 +32,8 @@ import ( scheme "k8s.io/client-go/kubernetes/scheme" rest "k8s.io/client-go/rest" consistencydetector "k8s.io/client-go/util/consistencydetector" + watchlist "k8s.io/client-go/util/watchlist" + "k8s.io/klog/v2" ) // ResourceClaimParametersGetter has a method to return a ResourceClaimParametersInterface. @@ -82,13 +84,22 @@ func (c *resourceClaimParameters) Get(ctx context.Context, name string, options } // List takes label and field selectors, and returns the list of ResourceClaimParameters that match those selectors. -func (c *resourceClaimParameters) List(ctx context.Context, opts v1.ListOptions) (result *v1alpha2.ResourceClaimParametersList, err error) { - defer func() { +func (c *resourceClaimParameters) List(ctx context.Context, opts v1.ListOptions) (*v1alpha2.ResourceClaimParametersList, error) { + if watchListOptions, hasWatchListOptionsPrepared, watchListOptionsErr := watchlist.PrepareWatchListOptionsFromListOptions(opts); watchListOptionsErr != nil { + klog.Warningf("Failed preparing watchlist options for resourceclaimparameters, falling back to the standard LIST semantics, err = %v", watchListOptionsErr) + } else if hasWatchListOptionsPrepared { + result, err := c.watchList(ctx, watchListOptions) if err == nil { - consistencydetector.CheckListFromCacheDataConsistencyIfRequested(ctx, "list request for resourceclaimparameters", c.list, opts, result) + consistencydetector.CheckWatchListFromCacheDataConsistencyIfRequested(ctx, "watchlist request for resourceclaimparameters", c.list, opts, result) + return result, nil } - }() - return c.list(ctx, opts) + klog.Warningf("The watchlist request for resourceclaimparameters ended with an error, falling back to the standard LIST semantics, err = %v", err) + } + result, err := c.list(ctx, opts) + if err == nil { + consistencydetector.CheckListFromCacheDataConsistencyIfRequested(ctx, "list request for resourceclaimparameters", c.list, opts, result) + } + return result, err } // list takes label and field selectors, and returns the list of ResourceClaimParameters that match those selectors. @@ -108,6 +119,23 @@ func (c *resourceClaimParameters) list(ctx context.Context, opts v1.ListOptions) return } +// watchList establishes a watch stream with the server and returns the list of ResourceClaimParameters +func (c *resourceClaimParameters) watchList(ctx context.Context, opts v1.ListOptions) (result *v1alpha2.ResourceClaimParametersList, err error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + result = &v1alpha2.ResourceClaimParametersList{} + err = c.client.Get(). + Namespace(c.ns). + Resource("resourceclaimparameters"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + WatchList(ctx). + Into(result) + return +} + // Watch returns a watch.Interface that watches the requested resourceClaimParameters. func (c *resourceClaimParameters) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { var timeout time.Duration diff --git a/staging/src/k8s.io/client-go/kubernetes/typed/resource/v1alpha2/resourceclaimtemplate.go b/staging/src/k8s.io/client-go/kubernetes/typed/resource/v1alpha2/resourceclaimtemplate.go index b9d7ab8333c..6257b6a4c47 100644 --- a/staging/src/k8s.io/client-go/kubernetes/typed/resource/v1alpha2/resourceclaimtemplate.go +++ b/staging/src/k8s.io/client-go/kubernetes/typed/resource/v1alpha2/resourceclaimtemplate.go @@ -32,6 +32,8 @@ import ( scheme "k8s.io/client-go/kubernetes/scheme" rest "k8s.io/client-go/rest" consistencydetector "k8s.io/client-go/util/consistencydetector" + watchlist "k8s.io/client-go/util/watchlist" + "k8s.io/klog/v2" ) // ResourceClaimTemplatesGetter has a method to return a ResourceClaimTemplateInterface. @@ -82,13 +84,22 @@ func (c *resourceClaimTemplates) Get(ctx context.Context, name string, options v } // List takes label and field selectors, and returns the list of ResourceClaimTemplates that match those selectors. -func (c *resourceClaimTemplates) List(ctx context.Context, opts v1.ListOptions) (result *v1alpha2.ResourceClaimTemplateList, err error) { - defer func() { +func (c *resourceClaimTemplates) List(ctx context.Context, opts v1.ListOptions) (*v1alpha2.ResourceClaimTemplateList, error) { + if watchListOptions, hasWatchListOptionsPrepared, watchListOptionsErr := watchlist.PrepareWatchListOptionsFromListOptions(opts); watchListOptionsErr != nil { + klog.Warningf("Failed preparing watchlist options for resourceclaimtemplates, falling back to the standard LIST semantics, err = %v", watchListOptionsErr) + } else if hasWatchListOptionsPrepared { + result, err := c.watchList(ctx, watchListOptions) if err == nil { - consistencydetector.CheckListFromCacheDataConsistencyIfRequested(ctx, "list request for resourceclaimtemplates", c.list, opts, result) + consistencydetector.CheckWatchListFromCacheDataConsistencyIfRequested(ctx, "watchlist request for resourceclaimtemplates", c.list, opts, result) + return result, nil } - }() - return c.list(ctx, opts) + klog.Warningf("The watchlist request for resourceclaimtemplates ended with an error, falling back to the standard LIST semantics, err = %v", err) + } + result, err := c.list(ctx, opts) + if err == nil { + consistencydetector.CheckListFromCacheDataConsistencyIfRequested(ctx, "list request for resourceclaimtemplates", c.list, opts, result) + } + return result, err } // list takes label and field selectors, and returns the list of ResourceClaimTemplates that match those selectors. @@ -108,6 +119,23 @@ func (c *resourceClaimTemplates) list(ctx context.Context, opts v1.ListOptions) return } +// watchList establishes a watch stream with the server and returns the list of ResourceClaimTemplates +func (c *resourceClaimTemplates) watchList(ctx context.Context, opts v1.ListOptions) (result *v1alpha2.ResourceClaimTemplateList, err error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + result = &v1alpha2.ResourceClaimTemplateList{} + err = c.client.Get(). + Namespace(c.ns). + Resource("resourceclaimtemplates"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + WatchList(ctx). + Into(result) + return +} + // Watch returns a watch.Interface that watches the requested resourceClaimTemplates. func (c *resourceClaimTemplates) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { var timeout time.Duration diff --git a/staging/src/k8s.io/client-go/kubernetes/typed/resource/v1alpha2/resourceclass.go b/staging/src/k8s.io/client-go/kubernetes/typed/resource/v1alpha2/resourceclass.go index 6a30db0bfda..0990fcb9065 100644 --- a/staging/src/k8s.io/client-go/kubernetes/typed/resource/v1alpha2/resourceclass.go +++ b/staging/src/k8s.io/client-go/kubernetes/typed/resource/v1alpha2/resourceclass.go @@ -32,6 +32,8 @@ import ( scheme "k8s.io/client-go/kubernetes/scheme" rest "k8s.io/client-go/rest" consistencydetector "k8s.io/client-go/util/consistencydetector" + watchlist "k8s.io/client-go/util/watchlist" + "k8s.io/klog/v2" ) // ResourceClassesGetter has a method to return a ResourceClassInterface. @@ -79,13 +81,22 @@ func (c *resourceClasses) Get(ctx context.Context, name string, options v1.GetOp } // List takes label and field selectors, and returns the list of ResourceClasses that match those selectors. -func (c *resourceClasses) List(ctx context.Context, opts v1.ListOptions) (result *v1alpha2.ResourceClassList, err error) { - defer func() { +func (c *resourceClasses) List(ctx context.Context, opts v1.ListOptions) (*v1alpha2.ResourceClassList, error) { + if watchListOptions, hasWatchListOptionsPrepared, watchListOptionsErr := watchlist.PrepareWatchListOptionsFromListOptions(opts); watchListOptionsErr != nil { + klog.Warningf("Failed preparing watchlist options for resourceclasses, falling back to the standard LIST semantics, err = %v", watchListOptionsErr) + } else if hasWatchListOptionsPrepared { + result, err := c.watchList(ctx, watchListOptions) if err == nil { - consistencydetector.CheckListFromCacheDataConsistencyIfRequested(ctx, "list request for resourceclasses", c.list, opts, result) + consistencydetector.CheckWatchListFromCacheDataConsistencyIfRequested(ctx, "watchlist request for resourceclasses", c.list, opts, result) + return result, nil } - }() - return c.list(ctx, opts) + klog.Warningf("The watchlist request for resourceclasses ended with an error, falling back to the standard LIST semantics, err = %v", err) + } + result, err := c.list(ctx, opts) + if err == nil { + consistencydetector.CheckListFromCacheDataConsistencyIfRequested(ctx, "list request for resourceclasses", c.list, opts, result) + } + return result, err } // list takes label and field selectors, and returns the list of ResourceClasses that match those selectors. @@ -104,6 +115,22 @@ func (c *resourceClasses) list(ctx context.Context, opts v1.ListOptions) (result return } +// watchList establishes a watch stream with the server and returns the list of ResourceClasses +func (c *resourceClasses) watchList(ctx context.Context, opts v1.ListOptions) (result *v1alpha2.ResourceClassList, err error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + result = &v1alpha2.ResourceClassList{} + err = c.client.Get(). + Resource("resourceclasses"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + WatchList(ctx). + Into(result) + return +} + // Watch returns a watch.Interface that watches the requested resourceClasses. func (c *resourceClasses) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { var timeout time.Duration diff --git a/staging/src/k8s.io/client-go/kubernetes/typed/resource/v1alpha2/resourceclassparameters.go b/staging/src/k8s.io/client-go/kubernetes/typed/resource/v1alpha2/resourceclassparameters.go index 7603c8b05f3..cedf4300c89 100644 --- a/staging/src/k8s.io/client-go/kubernetes/typed/resource/v1alpha2/resourceclassparameters.go +++ b/staging/src/k8s.io/client-go/kubernetes/typed/resource/v1alpha2/resourceclassparameters.go @@ -32,6 +32,8 @@ import ( scheme "k8s.io/client-go/kubernetes/scheme" rest "k8s.io/client-go/rest" consistencydetector "k8s.io/client-go/util/consistencydetector" + watchlist "k8s.io/client-go/util/watchlist" + "k8s.io/klog/v2" ) // ResourceClassParametersGetter has a method to return a ResourceClassParametersInterface. @@ -82,13 +84,22 @@ func (c *resourceClassParameters) Get(ctx context.Context, name string, options } // List takes label and field selectors, and returns the list of ResourceClassParameters that match those selectors. -func (c *resourceClassParameters) List(ctx context.Context, opts v1.ListOptions) (result *v1alpha2.ResourceClassParametersList, err error) { - defer func() { +func (c *resourceClassParameters) List(ctx context.Context, opts v1.ListOptions) (*v1alpha2.ResourceClassParametersList, error) { + if watchListOptions, hasWatchListOptionsPrepared, watchListOptionsErr := watchlist.PrepareWatchListOptionsFromListOptions(opts); watchListOptionsErr != nil { + klog.Warningf("Failed preparing watchlist options for resourceclassparameters, falling back to the standard LIST semantics, err = %v", watchListOptionsErr) + } else if hasWatchListOptionsPrepared { + result, err := c.watchList(ctx, watchListOptions) if err == nil { - consistencydetector.CheckListFromCacheDataConsistencyIfRequested(ctx, "list request for resourceclassparameters", c.list, opts, result) + consistencydetector.CheckWatchListFromCacheDataConsistencyIfRequested(ctx, "watchlist request for resourceclassparameters", c.list, opts, result) + return result, nil } - }() - return c.list(ctx, opts) + klog.Warningf("The watchlist request for resourceclassparameters ended with an error, falling back to the standard LIST semantics, err = %v", err) + } + result, err := c.list(ctx, opts) + if err == nil { + consistencydetector.CheckListFromCacheDataConsistencyIfRequested(ctx, "list request for resourceclassparameters", c.list, opts, result) + } + return result, err } // list takes label and field selectors, and returns the list of ResourceClassParameters that match those selectors. @@ -108,6 +119,23 @@ func (c *resourceClassParameters) list(ctx context.Context, opts v1.ListOptions) return } +// watchList establishes a watch stream with the server and returns the list of ResourceClassParameters +func (c *resourceClassParameters) watchList(ctx context.Context, opts v1.ListOptions) (result *v1alpha2.ResourceClassParametersList, err error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + result = &v1alpha2.ResourceClassParametersList{} + err = c.client.Get(). + Namespace(c.ns). + Resource("resourceclassparameters"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + WatchList(ctx). + Into(result) + return +} + // Watch returns a watch.Interface that watches the requested resourceClassParameters. func (c *resourceClassParameters) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { var timeout time.Duration diff --git a/staging/src/k8s.io/client-go/kubernetes/typed/resource/v1alpha2/resourceslice.go b/staging/src/k8s.io/client-go/kubernetes/typed/resource/v1alpha2/resourceslice.go index 29440c57945..9f6ce4322db 100644 --- a/staging/src/k8s.io/client-go/kubernetes/typed/resource/v1alpha2/resourceslice.go +++ b/staging/src/k8s.io/client-go/kubernetes/typed/resource/v1alpha2/resourceslice.go @@ -32,6 +32,8 @@ import ( scheme "k8s.io/client-go/kubernetes/scheme" rest "k8s.io/client-go/rest" consistencydetector "k8s.io/client-go/util/consistencydetector" + watchlist "k8s.io/client-go/util/watchlist" + "k8s.io/klog/v2" ) // ResourceSlicesGetter has a method to return a ResourceSliceInterface. @@ -79,13 +81,22 @@ func (c *resourceSlices) Get(ctx context.Context, name string, options v1.GetOpt } // List takes label and field selectors, and returns the list of ResourceSlices that match those selectors. -func (c *resourceSlices) List(ctx context.Context, opts v1.ListOptions) (result *v1alpha2.ResourceSliceList, err error) { - defer func() { +func (c *resourceSlices) List(ctx context.Context, opts v1.ListOptions) (*v1alpha2.ResourceSliceList, error) { + if watchListOptions, hasWatchListOptionsPrepared, watchListOptionsErr := watchlist.PrepareWatchListOptionsFromListOptions(opts); watchListOptionsErr != nil { + klog.Warningf("Failed preparing watchlist options for resourceslices, falling back to the standard LIST semantics, err = %v", watchListOptionsErr) + } else if hasWatchListOptionsPrepared { + result, err := c.watchList(ctx, watchListOptions) if err == nil { - consistencydetector.CheckListFromCacheDataConsistencyIfRequested(ctx, "list request for resourceslices", c.list, opts, result) + consistencydetector.CheckWatchListFromCacheDataConsistencyIfRequested(ctx, "watchlist request for resourceslices", c.list, opts, result) + return result, nil } - }() - return c.list(ctx, opts) + klog.Warningf("The watchlist request for resourceslices ended with an error, falling back to the standard LIST semantics, err = %v", err) + } + result, err := c.list(ctx, opts) + if err == nil { + consistencydetector.CheckListFromCacheDataConsistencyIfRequested(ctx, "list request for resourceslices", c.list, opts, result) + } + return result, err } // list takes label and field selectors, and returns the list of ResourceSlices that match those selectors. @@ -104,6 +115,22 @@ func (c *resourceSlices) list(ctx context.Context, opts v1.ListOptions) (result return } +// watchList establishes a watch stream with the server and returns the list of ResourceSlices +func (c *resourceSlices) watchList(ctx context.Context, opts v1.ListOptions) (result *v1alpha2.ResourceSliceList, err error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + result = &v1alpha2.ResourceSliceList{} + err = c.client.Get(). + Resource("resourceslices"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + WatchList(ctx). + Into(result) + return +} + // Watch returns a watch.Interface that watches the requested resourceSlices. func (c *resourceSlices) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { var timeout time.Duration diff --git a/staging/src/k8s.io/client-go/kubernetes/typed/scheduling/v1/priorityclass.go b/staging/src/k8s.io/client-go/kubernetes/typed/scheduling/v1/priorityclass.go index c7eb4c61673..ebc575e0465 100644 --- a/staging/src/k8s.io/client-go/kubernetes/typed/scheduling/v1/priorityclass.go +++ b/staging/src/k8s.io/client-go/kubernetes/typed/scheduling/v1/priorityclass.go @@ -32,6 +32,8 @@ import ( scheme "k8s.io/client-go/kubernetes/scheme" rest "k8s.io/client-go/rest" consistencydetector "k8s.io/client-go/util/consistencydetector" + watchlist "k8s.io/client-go/util/watchlist" + "k8s.io/klog/v2" ) // PriorityClassesGetter has a method to return a PriorityClassInterface. @@ -79,13 +81,22 @@ func (c *priorityClasses) Get(ctx context.Context, name string, options metav1.G } // List takes label and field selectors, and returns the list of PriorityClasses that match those selectors. -func (c *priorityClasses) List(ctx context.Context, opts metav1.ListOptions) (result *v1.PriorityClassList, err error) { - defer func() { +func (c *priorityClasses) List(ctx context.Context, opts metav1.ListOptions) (*v1.PriorityClassList, error) { + if watchListOptions, hasWatchListOptionsPrepared, watchListOptionsErr := watchlist.PrepareWatchListOptionsFromListOptions(opts); watchListOptionsErr != nil { + klog.Warningf("Failed preparing watchlist options for priorityclasses, falling back to the standard LIST semantics, err = %v", watchListOptionsErr) + } else if hasWatchListOptionsPrepared { + result, err := c.watchList(ctx, watchListOptions) if err == nil { - consistencydetector.CheckListFromCacheDataConsistencyIfRequested(ctx, "list request for priorityclasses", c.list, opts, result) + consistencydetector.CheckWatchListFromCacheDataConsistencyIfRequested(ctx, "watchlist request for priorityclasses", c.list, opts, result) + return result, nil } - }() - return c.list(ctx, opts) + klog.Warningf("The watchlist request for priorityclasses ended with an error, falling back to the standard LIST semantics, err = %v", err) + } + result, err := c.list(ctx, opts) + if err == nil { + consistencydetector.CheckListFromCacheDataConsistencyIfRequested(ctx, "list request for priorityclasses", c.list, opts, result) + } + return result, err } // list takes label and field selectors, and returns the list of PriorityClasses that match those selectors. @@ -104,6 +115,22 @@ func (c *priorityClasses) list(ctx context.Context, opts metav1.ListOptions) (re return } +// watchList establishes a watch stream with the server and returns the list of PriorityClasses +func (c *priorityClasses) watchList(ctx context.Context, opts metav1.ListOptions) (result *v1.PriorityClassList, err error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + result = &v1.PriorityClassList{} + err = c.client.Get(). + Resource("priorityclasses"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + WatchList(ctx). + Into(result) + return +} + // Watch returns a watch.Interface that watches the requested priorityClasses. func (c *priorityClasses) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { var timeout time.Duration diff --git a/staging/src/k8s.io/client-go/kubernetes/typed/scheduling/v1alpha1/priorityclass.go b/staging/src/k8s.io/client-go/kubernetes/typed/scheduling/v1alpha1/priorityclass.go index 40ce3437958..605ae7706d2 100644 --- a/staging/src/k8s.io/client-go/kubernetes/typed/scheduling/v1alpha1/priorityclass.go +++ b/staging/src/k8s.io/client-go/kubernetes/typed/scheduling/v1alpha1/priorityclass.go @@ -32,6 +32,8 @@ import ( scheme "k8s.io/client-go/kubernetes/scheme" rest "k8s.io/client-go/rest" consistencydetector "k8s.io/client-go/util/consistencydetector" + watchlist "k8s.io/client-go/util/watchlist" + "k8s.io/klog/v2" ) // PriorityClassesGetter has a method to return a PriorityClassInterface. @@ -79,13 +81,22 @@ func (c *priorityClasses) Get(ctx context.Context, name string, options v1.GetOp } // List takes label and field selectors, and returns the list of PriorityClasses that match those selectors. -func (c *priorityClasses) List(ctx context.Context, opts v1.ListOptions) (result *v1alpha1.PriorityClassList, err error) { - defer func() { +func (c *priorityClasses) List(ctx context.Context, opts v1.ListOptions) (*v1alpha1.PriorityClassList, error) { + if watchListOptions, hasWatchListOptionsPrepared, watchListOptionsErr := watchlist.PrepareWatchListOptionsFromListOptions(opts); watchListOptionsErr != nil { + klog.Warningf("Failed preparing watchlist options for priorityclasses, falling back to the standard LIST semantics, err = %v", watchListOptionsErr) + } else if hasWatchListOptionsPrepared { + result, err := c.watchList(ctx, watchListOptions) if err == nil { - consistencydetector.CheckListFromCacheDataConsistencyIfRequested(ctx, "list request for priorityclasses", c.list, opts, result) + consistencydetector.CheckWatchListFromCacheDataConsistencyIfRequested(ctx, "watchlist request for priorityclasses", c.list, opts, result) + return result, nil } - }() - return c.list(ctx, opts) + klog.Warningf("The watchlist request for priorityclasses ended with an error, falling back to the standard LIST semantics, err = %v", err) + } + result, err := c.list(ctx, opts) + if err == nil { + consistencydetector.CheckListFromCacheDataConsistencyIfRequested(ctx, "list request for priorityclasses", c.list, opts, result) + } + return result, err } // list takes label and field selectors, and returns the list of PriorityClasses that match those selectors. @@ -104,6 +115,22 @@ func (c *priorityClasses) list(ctx context.Context, opts v1.ListOptions) (result return } +// watchList establishes a watch stream with the server and returns the list of PriorityClasses +func (c *priorityClasses) watchList(ctx context.Context, opts v1.ListOptions) (result *v1alpha1.PriorityClassList, err error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + result = &v1alpha1.PriorityClassList{} + err = c.client.Get(). + Resource("priorityclasses"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + WatchList(ctx). + Into(result) + return +} + // Watch returns a watch.Interface that watches the requested priorityClasses. func (c *priorityClasses) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { var timeout time.Duration diff --git a/staging/src/k8s.io/client-go/kubernetes/typed/scheduling/v1beta1/priorityclass.go b/staging/src/k8s.io/client-go/kubernetes/typed/scheduling/v1beta1/priorityclass.go index d22d9bafc51..561c9adc960 100644 --- a/staging/src/k8s.io/client-go/kubernetes/typed/scheduling/v1beta1/priorityclass.go +++ b/staging/src/k8s.io/client-go/kubernetes/typed/scheduling/v1beta1/priorityclass.go @@ -32,6 +32,8 @@ import ( scheme "k8s.io/client-go/kubernetes/scheme" rest "k8s.io/client-go/rest" consistencydetector "k8s.io/client-go/util/consistencydetector" + watchlist "k8s.io/client-go/util/watchlist" + "k8s.io/klog/v2" ) // PriorityClassesGetter has a method to return a PriorityClassInterface. @@ -79,13 +81,22 @@ func (c *priorityClasses) Get(ctx context.Context, name string, options v1.GetOp } // List takes label and field selectors, and returns the list of PriorityClasses that match those selectors. -func (c *priorityClasses) List(ctx context.Context, opts v1.ListOptions) (result *v1beta1.PriorityClassList, err error) { - defer func() { +func (c *priorityClasses) List(ctx context.Context, opts v1.ListOptions) (*v1beta1.PriorityClassList, error) { + if watchListOptions, hasWatchListOptionsPrepared, watchListOptionsErr := watchlist.PrepareWatchListOptionsFromListOptions(opts); watchListOptionsErr != nil { + klog.Warningf("Failed preparing watchlist options for priorityclasses, falling back to the standard LIST semantics, err = %v", watchListOptionsErr) + } else if hasWatchListOptionsPrepared { + result, err := c.watchList(ctx, watchListOptions) if err == nil { - consistencydetector.CheckListFromCacheDataConsistencyIfRequested(ctx, "list request for priorityclasses", c.list, opts, result) + consistencydetector.CheckWatchListFromCacheDataConsistencyIfRequested(ctx, "watchlist request for priorityclasses", c.list, opts, result) + return result, nil } - }() - return c.list(ctx, opts) + klog.Warningf("The watchlist request for priorityclasses ended with an error, falling back to the standard LIST semantics, err = %v", err) + } + result, err := c.list(ctx, opts) + if err == nil { + consistencydetector.CheckListFromCacheDataConsistencyIfRequested(ctx, "list request for priorityclasses", c.list, opts, result) + } + return result, err } // list takes label and field selectors, and returns the list of PriorityClasses that match those selectors. @@ -104,6 +115,22 @@ func (c *priorityClasses) list(ctx context.Context, opts v1.ListOptions) (result return } +// watchList establishes a watch stream with the server and returns the list of PriorityClasses +func (c *priorityClasses) watchList(ctx context.Context, opts v1.ListOptions) (result *v1beta1.PriorityClassList, err error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + result = &v1beta1.PriorityClassList{} + err = c.client.Get(). + Resource("priorityclasses"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + WatchList(ctx). + Into(result) + return +} + // Watch returns a watch.Interface that watches the requested priorityClasses. func (c *priorityClasses) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { var timeout time.Duration diff --git a/staging/src/k8s.io/client-go/kubernetes/typed/storage/v1/csidriver.go b/staging/src/k8s.io/client-go/kubernetes/typed/storage/v1/csidriver.go index afb10669315..b07cb4f3531 100644 --- a/staging/src/k8s.io/client-go/kubernetes/typed/storage/v1/csidriver.go +++ b/staging/src/k8s.io/client-go/kubernetes/typed/storage/v1/csidriver.go @@ -32,6 +32,8 @@ import ( scheme "k8s.io/client-go/kubernetes/scheme" rest "k8s.io/client-go/rest" consistencydetector "k8s.io/client-go/util/consistencydetector" + watchlist "k8s.io/client-go/util/watchlist" + "k8s.io/klog/v2" ) // CSIDriversGetter has a method to return a CSIDriverInterface. @@ -79,13 +81,22 @@ func (c *cSIDrivers) Get(ctx context.Context, name string, options metav1.GetOpt } // List takes label and field selectors, and returns the list of CSIDrivers that match those selectors. -func (c *cSIDrivers) List(ctx context.Context, opts metav1.ListOptions) (result *v1.CSIDriverList, err error) { - defer func() { +func (c *cSIDrivers) List(ctx context.Context, opts metav1.ListOptions) (*v1.CSIDriverList, error) { + if watchListOptions, hasWatchListOptionsPrepared, watchListOptionsErr := watchlist.PrepareWatchListOptionsFromListOptions(opts); watchListOptionsErr != nil { + klog.Warningf("Failed preparing watchlist options for csidrivers, falling back to the standard LIST semantics, err = %v", watchListOptionsErr) + } else if hasWatchListOptionsPrepared { + result, err := c.watchList(ctx, watchListOptions) if err == nil { - consistencydetector.CheckListFromCacheDataConsistencyIfRequested(ctx, "list request for csidrivers", c.list, opts, result) + consistencydetector.CheckWatchListFromCacheDataConsistencyIfRequested(ctx, "watchlist request for csidrivers", c.list, opts, result) + return result, nil } - }() - return c.list(ctx, opts) + klog.Warningf("The watchlist request for csidrivers ended with an error, falling back to the standard LIST semantics, err = %v", err) + } + result, err := c.list(ctx, opts) + if err == nil { + consistencydetector.CheckListFromCacheDataConsistencyIfRequested(ctx, "list request for csidrivers", c.list, opts, result) + } + return result, err } // list takes label and field selectors, and returns the list of CSIDrivers that match those selectors. @@ -104,6 +115,22 @@ func (c *cSIDrivers) list(ctx context.Context, opts metav1.ListOptions) (result return } +// watchList establishes a watch stream with the server and returns the list of CSIDrivers +func (c *cSIDrivers) watchList(ctx context.Context, opts metav1.ListOptions) (result *v1.CSIDriverList, err error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + result = &v1.CSIDriverList{} + err = c.client.Get(). + Resource("csidrivers"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + WatchList(ctx). + Into(result) + return +} + // Watch returns a watch.Interface that watches the requested cSIDrivers. func (c *cSIDrivers) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { var timeout time.Duration diff --git a/staging/src/k8s.io/client-go/kubernetes/typed/storage/v1/csinode.go b/staging/src/k8s.io/client-go/kubernetes/typed/storage/v1/csinode.go index 4d5ce7899bf..308ae9ce08e 100644 --- a/staging/src/k8s.io/client-go/kubernetes/typed/storage/v1/csinode.go +++ b/staging/src/k8s.io/client-go/kubernetes/typed/storage/v1/csinode.go @@ -32,6 +32,8 @@ import ( scheme "k8s.io/client-go/kubernetes/scheme" rest "k8s.io/client-go/rest" consistencydetector "k8s.io/client-go/util/consistencydetector" + watchlist "k8s.io/client-go/util/watchlist" + "k8s.io/klog/v2" ) // CSINodesGetter has a method to return a CSINodeInterface. @@ -79,13 +81,22 @@ func (c *cSINodes) Get(ctx context.Context, name string, options metav1.GetOptio } // List takes label and field selectors, and returns the list of CSINodes that match those selectors. -func (c *cSINodes) List(ctx context.Context, opts metav1.ListOptions) (result *v1.CSINodeList, err error) { - defer func() { +func (c *cSINodes) List(ctx context.Context, opts metav1.ListOptions) (*v1.CSINodeList, error) { + if watchListOptions, hasWatchListOptionsPrepared, watchListOptionsErr := watchlist.PrepareWatchListOptionsFromListOptions(opts); watchListOptionsErr != nil { + klog.Warningf("Failed preparing watchlist options for csinodes, falling back to the standard LIST semantics, err = %v", watchListOptionsErr) + } else if hasWatchListOptionsPrepared { + result, err := c.watchList(ctx, watchListOptions) if err == nil { - consistencydetector.CheckListFromCacheDataConsistencyIfRequested(ctx, "list request for csinodes", c.list, opts, result) + consistencydetector.CheckWatchListFromCacheDataConsistencyIfRequested(ctx, "watchlist request for csinodes", c.list, opts, result) + return result, nil } - }() - return c.list(ctx, opts) + klog.Warningf("The watchlist request for csinodes ended with an error, falling back to the standard LIST semantics, err = %v", err) + } + result, err := c.list(ctx, opts) + if err == nil { + consistencydetector.CheckListFromCacheDataConsistencyIfRequested(ctx, "list request for csinodes", c.list, opts, result) + } + return result, err } // list takes label and field selectors, and returns the list of CSINodes that match those selectors. @@ -104,6 +115,22 @@ func (c *cSINodes) list(ctx context.Context, opts metav1.ListOptions) (result *v return } +// watchList establishes a watch stream with the server and returns the list of CSINodes +func (c *cSINodes) watchList(ctx context.Context, opts metav1.ListOptions) (result *v1.CSINodeList, err error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + result = &v1.CSINodeList{} + err = c.client.Get(). + Resource("csinodes"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + WatchList(ctx). + Into(result) + return +} + // Watch returns a watch.Interface that watches the requested cSINodes. func (c *cSINodes) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { var timeout time.Duration diff --git a/staging/src/k8s.io/client-go/kubernetes/typed/storage/v1/csistoragecapacity.go b/staging/src/k8s.io/client-go/kubernetes/typed/storage/v1/csistoragecapacity.go index 4c3e1f249a8..f80825633ce 100644 --- a/staging/src/k8s.io/client-go/kubernetes/typed/storage/v1/csistoragecapacity.go +++ b/staging/src/k8s.io/client-go/kubernetes/typed/storage/v1/csistoragecapacity.go @@ -32,6 +32,8 @@ import ( scheme "k8s.io/client-go/kubernetes/scheme" rest "k8s.io/client-go/rest" consistencydetector "k8s.io/client-go/util/consistencydetector" + watchlist "k8s.io/client-go/util/watchlist" + "k8s.io/klog/v2" ) // CSIStorageCapacitiesGetter has a method to return a CSIStorageCapacityInterface. @@ -82,13 +84,22 @@ func (c *cSIStorageCapacities) Get(ctx context.Context, name string, options met } // List takes label and field selectors, and returns the list of CSIStorageCapacities that match those selectors. -func (c *cSIStorageCapacities) List(ctx context.Context, opts metav1.ListOptions) (result *v1.CSIStorageCapacityList, err error) { - defer func() { +func (c *cSIStorageCapacities) List(ctx context.Context, opts metav1.ListOptions) (*v1.CSIStorageCapacityList, error) { + if watchListOptions, hasWatchListOptionsPrepared, watchListOptionsErr := watchlist.PrepareWatchListOptionsFromListOptions(opts); watchListOptionsErr != nil { + klog.Warningf("Failed preparing watchlist options for csistoragecapacities, falling back to the standard LIST semantics, err = %v", watchListOptionsErr) + } else if hasWatchListOptionsPrepared { + result, err := c.watchList(ctx, watchListOptions) if err == nil { - consistencydetector.CheckListFromCacheDataConsistencyIfRequested(ctx, "list request for csistoragecapacities", c.list, opts, result) + consistencydetector.CheckWatchListFromCacheDataConsistencyIfRequested(ctx, "watchlist request for csistoragecapacities", c.list, opts, result) + return result, nil } - }() - return c.list(ctx, opts) + klog.Warningf("The watchlist request for csistoragecapacities ended with an error, falling back to the standard LIST semantics, err = %v", err) + } + result, err := c.list(ctx, opts) + if err == nil { + consistencydetector.CheckListFromCacheDataConsistencyIfRequested(ctx, "list request for csistoragecapacities", c.list, opts, result) + } + return result, err } // list takes label and field selectors, and returns the list of CSIStorageCapacities that match those selectors. @@ -108,6 +119,23 @@ func (c *cSIStorageCapacities) list(ctx context.Context, opts metav1.ListOptions return } +// watchList establishes a watch stream with the server and returns the list of CSIStorageCapacities +func (c *cSIStorageCapacities) watchList(ctx context.Context, opts metav1.ListOptions) (result *v1.CSIStorageCapacityList, err error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + result = &v1.CSIStorageCapacityList{} + err = c.client.Get(). + Namespace(c.ns). + Resource("csistoragecapacities"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + WatchList(ctx). + Into(result) + return +} + // Watch returns a watch.Interface that watches the requested cSIStorageCapacities. func (c *cSIStorageCapacities) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { var timeout time.Duration diff --git a/staging/src/k8s.io/client-go/kubernetes/typed/storage/v1/storageclass.go b/staging/src/k8s.io/client-go/kubernetes/typed/storage/v1/storageclass.go index cce61b2c066..e012275b4c6 100644 --- a/staging/src/k8s.io/client-go/kubernetes/typed/storage/v1/storageclass.go +++ b/staging/src/k8s.io/client-go/kubernetes/typed/storage/v1/storageclass.go @@ -32,6 +32,8 @@ import ( scheme "k8s.io/client-go/kubernetes/scheme" rest "k8s.io/client-go/rest" consistencydetector "k8s.io/client-go/util/consistencydetector" + watchlist "k8s.io/client-go/util/watchlist" + "k8s.io/klog/v2" ) // StorageClassesGetter has a method to return a StorageClassInterface. @@ -79,13 +81,22 @@ func (c *storageClasses) Get(ctx context.Context, name string, options metav1.Ge } // List takes label and field selectors, and returns the list of StorageClasses that match those selectors. -func (c *storageClasses) List(ctx context.Context, opts metav1.ListOptions) (result *v1.StorageClassList, err error) { - defer func() { +func (c *storageClasses) List(ctx context.Context, opts metav1.ListOptions) (*v1.StorageClassList, error) { + if watchListOptions, hasWatchListOptionsPrepared, watchListOptionsErr := watchlist.PrepareWatchListOptionsFromListOptions(opts); watchListOptionsErr != nil { + klog.Warningf("Failed preparing watchlist options for storageclasses, falling back to the standard LIST semantics, err = %v", watchListOptionsErr) + } else if hasWatchListOptionsPrepared { + result, err := c.watchList(ctx, watchListOptions) if err == nil { - consistencydetector.CheckListFromCacheDataConsistencyIfRequested(ctx, "list request for storageclasses", c.list, opts, result) + consistencydetector.CheckWatchListFromCacheDataConsistencyIfRequested(ctx, "watchlist request for storageclasses", c.list, opts, result) + return result, nil } - }() - return c.list(ctx, opts) + klog.Warningf("The watchlist request for storageclasses ended with an error, falling back to the standard LIST semantics, err = %v", err) + } + result, err := c.list(ctx, opts) + if err == nil { + consistencydetector.CheckListFromCacheDataConsistencyIfRequested(ctx, "list request for storageclasses", c.list, opts, result) + } + return result, err } // list takes label and field selectors, and returns the list of StorageClasses that match those selectors. @@ -104,6 +115,22 @@ func (c *storageClasses) list(ctx context.Context, opts metav1.ListOptions) (res return } +// watchList establishes a watch stream with the server and returns the list of StorageClasses +func (c *storageClasses) watchList(ctx context.Context, opts metav1.ListOptions) (result *v1.StorageClassList, err error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + result = &v1.StorageClassList{} + err = c.client.Get(). + Resource("storageclasses"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + WatchList(ctx). + Into(result) + return +} + // Watch returns a watch.Interface that watches the requested storageClasses. func (c *storageClasses) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { var timeout time.Duration diff --git a/staging/src/k8s.io/client-go/kubernetes/typed/storage/v1/volumeattachment.go b/staging/src/k8s.io/client-go/kubernetes/typed/storage/v1/volumeattachment.go index c29fe448660..503093e428a 100644 --- a/staging/src/k8s.io/client-go/kubernetes/typed/storage/v1/volumeattachment.go +++ b/staging/src/k8s.io/client-go/kubernetes/typed/storage/v1/volumeattachment.go @@ -32,6 +32,8 @@ import ( scheme "k8s.io/client-go/kubernetes/scheme" rest "k8s.io/client-go/rest" consistencydetector "k8s.io/client-go/util/consistencydetector" + watchlist "k8s.io/client-go/util/watchlist" + "k8s.io/klog/v2" ) // VolumeAttachmentsGetter has a method to return a VolumeAttachmentInterface. @@ -81,13 +83,22 @@ func (c *volumeAttachments) Get(ctx context.Context, name string, options metav1 } // List takes label and field selectors, and returns the list of VolumeAttachments that match those selectors. -func (c *volumeAttachments) List(ctx context.Context, opts metav1.ListOptions) (result *v1.VolumeAttachmentList, err error) { - defer func() { +func (c *volumeAttachments) List(ctx context.Context, opts metav1.ListOptions) (*v1.VolumeAttachmentList, error) { + if watchListOptions, hasWatchListOptionsPrepared, watchListOptionsErr := watchlist.PrepareWatchListOptionsFromListOptions(opts); watchListOptionsErr != nil { + klog.Warningf("Failed preparing watchlist options for volumeattachments, falling back to the standard LIST semantics, err = %v", watchListOptionsErr) + } else if hasWatchListOptionsPrepared { + result, err := c.watchList(ctx, watchListOptions) if err == nil { - consistencydetector.CheckListFromCacheDataConsistencyIfRequested(ctx, "list request for volumeattachments", c.list, opts, result) + consistencydetector.CheckWatchListFromCacheDataConsistencyIfRequested(ctx, "watchlist request for volumeattachments", c.list, opts, result) + return result, nil } - }() - return c.list(ctx, opts) + klog.Warningf("The watchlist request for volumeattachments ended with an error, falling back to the standard LIST semantics, err = %v", err) + } + result, err := c.list(ctx, opts) + if err == nil { + consistencydetector.CheckListFromCacheDataConsistencyIfRequested(ctx, "list request for volumeattachments", c.list, opts, result) + } + return result, err } // list takes label and field selectors, and returns the list of VolumeAttachments that match those selectors. @@ -106,6 +117,22 @@ func (c *volumeAttachments) list(ctx context.Context, opts metav1.ListOptions) ( return } +// watchList establishes a watch stream with the server and returns the list of VolumeAttachments +func (c *volumeAttachments) watchList(ctx context.Context, opts metav1.ListOptions) (result *v1.VolumeAttachmentList, err error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + result = &v1.VolumeAttachmentList{} + err = c.client.Get(). + Resource("volumeattachments"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + WatchList(ctx). + Into(result) + return +} + // Watch returns a watch.Interface that watches the requested volumeAttachments. func (c *volumeAttachments) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { var timeout time.Duration diff --git a/staging/src/k8s.io/client-go/kubernetes/typed/storage/v1alpha1/csistoragecapacity.go b/staging/src/k8s.io/client-go/kubernetes/typed/storage/v1alpha1/csistoragecapacity.go index 2d464baa6f3..b8923b0fc1f 100644 --- a/staging/src/k8s.io/client-go/kubernetes/typed/storage/v1alpha1/csistoragecapacity.go +++ b/staging/src/k8s.io/client-go/kubernetes/typed/storage/v1alpha1/csistoragecapacity.go @@ -32,6 +32,8 @@ import ( scheme "k8s.io/client-go/kubernetes/scheme" rest "k8s.io/client-go/rest" consistencydetector "k8s.io/client-go/util/consistencydetector" + watchlist "k8s.io/client-go/util/watchlist" + "k8s.io/klog/v2" ) // CSIStorageCapacitiesGetter has a method to return a CSIStorageCapacityInterface. @@ -82,13 +84,22 @@ func (c *cSIStorageCapacities) Get(ctx context.Context, name string, options v1. } // List takes label and field selectors, and returns the list of CSIStorageCapacities that match those selectors. -func (c *cSIStorageCapacities) List(ctx context.Context, opts v1.ListOptions) (result *v1alpha1.CSIStorageCapacityList, err error) { - defer func() { +func (c *cSIStorageCapacities) List(ctx context.Context, opts v1.ListOptions) (*v1alpha1.CSIStorageCapacityList, error) { + if watchListOptions, hasWatchListOptionsPrepared, watchListOptionsErr := watchlist.PrepareWatchListOptionsFromListOptions(opts); watchListOptionsErr != nil { + klog.Warningf("Failed preparing watchlist options for csistoragecapacities, falling back to the standard LIST semantics, err = %v", watchListOptionsErr) + } else if hasWatchListOptionsPrepared { + result, err := c.watchList(ctx, watchListOptions) if err == nil { - consistencydetector.CheckListFromCacheDataConsistencyIfRequested(ctx, "list request for csistoragecapacities", c.list, opts, result) + consistencydetector.CheckWatchListFromCacheDataConsistencyIfRequested(ctx, "watchlist request for csistoragecapacities", c.list, opts, result) + return result, nil } - }() - return c.list(ctx, opts) + klog.Warningf("The watchlist request for csistoragecapacities ended with an error, falling back to the standard LIST semantics, err = %v", err) + } + result, err := c.list(ctx, opts) + if err == nil { + consistencydetector.CheckListFromCacheDataConsistencyIfRequested(ctx, "list request for csistoragecapacities", c.list, opts, result) + } + return result, err } // list takes label and field selectors, and returns the list of CSIStorageCapacities that match those selectors. @@ -108,6 +119,23 @@ func (c *cSIStorageCapacities) list(ctx context.Context, opts v1.ListOptions) (r return } +// watchList establishes a watch stream with the server and returns the list of CSIStorageCapacities +func (c *cSIStorageCapacities) watchList(ctx context.Context, opts v1.ListOptions) (result *v1alpha1.CSIStorageCapacityList, err error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + result = &v1alpha1.CSIStorageCapacityList{} + err = c.client.Get(). + Namespace(c.ns). + Resource("csistoragecapacities"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + WatchList(ctx). + Into(result) + return +} + // Watch returns a watch.Interface that watches the requested cSIStorageCapacities. func (c *cSIStorageCapacities) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { var timeout time.Duration diff --git a/staging/src/k8s.io/client-go/kubernetes/typed/storage/v1alpha1/volumeattachment.go b/staging/src/k8s.io/client-go/kubernetes/typed/storage/v1alpha1/volumeattachment.go index 69aa9d8a279..c782f462167 100644 --- a/staging/src/k8s.io/client-go/kubernetes/typed/storage/v1alpha1/volumeattachment.go +++ b/staging/src/k8s.io/client-go/kubernetes/typed/storage/v1alpha1/volumeattachment.go @@ -32,6 +32,8 @@ import ( scheme "k8s.io/client-go/kubernetes/scheme" rest "k8s.io/client-go/rest" consistencydetector "k8s.io/client-go/util/consistencydetector" + watchlist "k8s.io/client-go/util/watchlist" + "k8s.io/klog/v2" ) // VolumeAttachmentsGetter has a method to return a VolumeAttachmentInterface. @@ -81,13 +83,22 @@ func (c *volumeAttachments) Get(ctx context.Context, name string, options v1.Get } // List takes label and field selectors, and returns the list of VolumeAttachments that match those selectors. -func (c *volumeAttachments) List(ctx context.Context, opts v1.ListOptions) (result *v1alpha1.VolumeAttachmentList, err error) { - defer func() { +func (c *volumeAttachments) List(ctx context.Context, opts v1.ListOptions) (*v1alpha1.VolumeAttachmentList, error) { + if watchListOptions, hasWatchListOptionsPrepared, watchListOptionsErr := watchlist.PrepareWatchListOptionsFromListOptions(opts); watchListOptionsErr != nil { + klog.Warningf("Failed preparing watchlist options for volumeattachments, falling back to the standard LIST semantics, err = %v", watchListOptionsErr) + } else if hasWatchListOptionsPrepared { + result, err := c.watchList(ctx, watchListOptions) if err == nil { - consistencydetector.CheckListFromCacheDataConsistencyIfRequested(ctx, "list request for volumeattachments", c.list, opts, result) + consistencydetector.CheckWatchListFromCacheDataConsistencyIfRequested(ctx, "watchlist request for volumeattachments", c.list, opts, result) + return result, nil } - }() - return c.list(ctx, opts) + klog.Warningf("The watchlist request for volumeattachments ended with an error, falling back to the standard LIST semantics, err = %v", err) + } + result, err := c.list(ctx, opts) + if err == nil { + consistencydetector.CheckListFromCacheDataConsistencyIfRequested(ctx, "list request for volumeattachments", c.list, opts, result) + } + return result, err } // list takes label and field selectors, and returns the list of VolumeAttachments that match those selectors. @@ -106,6 +117,22 @@ func (c *volumeAttachments) list(ctx context.Context, opts v1.ListOptions) (resu return } +// watchList establishes a watch stream with the server and returns the list of VolumeAttachments +func (c *volumeAttachments) watchList(ctx context.Context, opts v1.ListOptions) (result *v1alpha1.VolumeAttachmentList, err error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + result = &v1alpha1.VolumeAttachmentList{} + err = c.client.Get(). + Resource("volumeattachments"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + WatchList(ctx). + Into(result) + return +} + // Watch returns a watch.Interface that watches the requested volumeAttachments. func (c *volumeAttachments) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { var timeout time.Duration diff --git a/staging/src/k8s.io/client-go/kubernetes/typed/storage/v1alpha1/volumeattributesclass.go b/staging/src/k8s.io/client-go/kubernetes/typed/storage/v1alpha1/volumeattributesclass.go index e049d94b2c6..c9bf5b2ddd7 100644 --- a/staging/src/k8s.io/client-go/kubernetes/typed/storage/v1alpha1/volumeattributesclass.go +++ b/staging/src/k8s.io/client-go/kubernetes/typed/storage/v1alpha1/volumeattributesclass.go @@ -32,6 +32,8 @@ import ( scheme "k8s.io/client-go/kubernetes/scheme" rest "k8s.io/client-go/rest" consistencydetector "k8s.io/client-go/util/consistencydetector" + watchlist "k8s.io/client-go/util/watchlist" + "k8s.io/klog/v2" ) // VolumeAttributesClassesGetter has a method to return a VolumeAttributesClassInterface. @@ -79,13 +81,22 @@ func (c *volumeAttributesClasses) Get(ctx context.Context, name string, options } // List takes label and field selectors, and returns the list of VolumeAttributesClasses that match those selectors. -func (c *volumeAttributesClasses) List(ctx context.Context, opts v1.ListOptions) (result *v1alpha1.VolumeAttributesClassList, err error) { - defer func() { +func (c *volumeAttributesClasses) List(ctx context.Context, opts v1.ListOptions) (*v1alpha1.VolumeAttributesClassList, error) { + if watchListOptions, hasWatchListOptionsPrepared, watchListOptionsErr := watchlist.PrepareWatchListOptionsFromListOptions(opts); watchListOptionsErr != nil { + klog.Warningf("Failed preparing watchlist options for volumeattributesclasses, falling back to the standard LIST semantics, err = %v", watchListOptionsErr) + } else if hasWatchListOptionsPrepared { + result, err := c.watchList(ctx, watchListOptions) if err == nil { - consistencydetector.CheckListFromCacheDataConsistencyIfRequested(ctx, "list request for volumeattributesclasses", c.list, opts, result) + consistencydetector.CheckWatchListFromCacheDataConsistencyIfRequested(ctx, "watchlist request for volumeattributesclasses", c.list, opts, result) + return result, nil } - }() - return c.list(ctx, opts) + klog.Warningf("The watchlist request for volumeattributesclasses ended with an error, falling back to the standard LIST semantics, err = %v", err) + } + result, err := c.list(ctx, opts) + if err == nil { + consistencydetector.CheckListFromCacheDataConsistencyIfRequested(ctx, "list request for volumeattributesclasses", c.list, opts, result) + } + return result, err } // list takes label and field selectors, and returns the list of VolumeAttributesClasses that match those selectors. @@ -104,6 +115,22 @@ func (c *volumeAttributesClasses) list(ctx context.Context, opts v1.ListOptions) return } +// watchList establishes a watch stream with the server and returns the list of VolumeAttributesClasses +func (c *volumeAttributesClasses) watchList(ctx context.Context, opts v1.ListOptions) (result *v1alpha1.VolumeAttributesClassList, err error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + result = &v1alpha1.VolumeAttributesClassList{} + err = c.client.Get(). + Resource("volumeattributesclasses"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + WatchList(ctx). + Into(result) + return +} + // Watch returns a watch.Interface that watches the requested volumeAttributesClasses. func (c *volumeAttributesClasses) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { var timeout time.Duration diff --git a/staging/src/k8s.io/client-go/kubernetes/typed/storage/v1beta1/csidriver.go b/staging/src/k8s.io/client-go/kubernetes/typed/storage/v1beta1/csidriver.go index 861a9c0512a..c6205cb867d 100644 --- a/staging/src/k8s.io/client-go/kubernetes/typed/storage/v1beta1/csidriver.go +++ b/staging/src/k8s.io/client-go/kubernetes/typed/storage/v1beta1/csidriver.go @@ -32,6 +32,8 @@ import ( scheme "k8s.io/client-go/kubernetes/scheme" rest "k8s.io/client-go/rest" consistencydetector "k8s.io/client-go/util/consistencydetector" + watchlist "k8s.io/client-go/util/watchlist" + "k8s.io/klog/v2" ) // CSIDriversGetter has a method to return a CSIDriverInterface. @@ -79,13 +81,22 @@ func (c *cSIDrivers) Get(ctx context.Context, name string, options v1.GetOptions } // List takes label and field selectors, and returns the list of CSIDrivers that match those selectors. -func (c *cSIDrivers) List(ctx context.Context, opts v1.ListOptions) (result *v1beta1.CSIDriverList, err error) { - defer func() { +func (c *cSIDrivers) List(ctx context.Context, opts v1.ListOptions) (*v1beta1.CSIDriverList, error) { + if watchListOptions, hasWatchListOptionsPrepared, watchListOptionsErr := watchlist.PrepareWatchListOptionsFromListOptions(opts); watchListOptionsErr != nil { + klog.Warningf("Failed preparing watchlist options for csidrivers, falling back to the standard LIST semantics, err = %v", watchListOptionsErr) + } else if hasWatchListOptionsPrepared { + result, err := c.watchList(ctx, watchListOptions) if err == nil { - consistencydetector.CheckListFromCacheDataConsistencyIfRequested(ctx, "list request for csidrivers", c.list, opts, result) + consistencydetector.CheckWatchListFromCacheDataConsistencyIfRequested(ctx, "watchlist request for csidrivers", c.list, opts, result) + return result, nil } - }() - return c.list(ctx, opts) + klog.Warningf("The watchlist request for csidrivers ended with an error, falling back to the standard LIST semantics, err = %v", err) + } + result, err := c.list(ctx, opts) + if err == nil { + consistencydetector.CheckListFromCacheDataConsistencyIfRequested(ctx, "list request for csidrivers", c.list, opts, result) + } + return result, err } // list takes label and field selectors, and returns the list of CSIDrivers that match those selectors. @@ -104,6 +115,22 @@ func (c *cSIDrivers) list(ctx context.Context, opts v1.ListOptions) (result *v1b return } +// watchList establishes a watch stream with the server and returns the list of CSIDrivers +func (c *cSIDrivers) watchList(ctx context.Context, opts v1.ListOptions) (result *v1beta1.CSIDriverList, err error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + result = &v1beta1.CSIDriverList{} + err = c.client.Get(). + Resource("csidrivers"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + WatchList(ctx). + Into(result) + return +} + // Watch returns a watch.Interface that watches the requested cSIDrivers. func (c *cSIDrivers) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { var timeout time.Duration diff --git a/staging/src/k8s.io/client-go/kubernetes/typed/storage/v1beta1/csinode.go b/staging/src/k8s.io/client-go/kubernetes/typed/storage/v1beta1/csinode.go index effe3d98a02..4c0fefc7644 100644 --- a/staging/src/k8s.io/client-go/kubernetes/typed/storage/v1beta1/csinode.go +++ b/staging/src/k8s.io/client-go/kubernetes/typed/storage/v1beta1/csinode.go @@ -32,6 +32,8 @@ import ( scheme "k8s.io/client-go/kubernetes/scheme" rest "k8s.io/client-go/rest" consistencydetector "k8s.io/client-go/util/consistencydetector" + watchlist "k8s.io/client-go/util/watchlist" + "k8s.io/klog/v2" ) // CSINodesGetter has a method to return a CSINodeInterface. @@ -79,13 +81,22 @@ func (c *cSINodes) Get(ctx context.Context, name string, options v1.GetOptions) } // List takes label and field selectors, and returns the list of CSINodes that match those selectors. -func (c *cSINodes) List(ctx context.Context, opts v1.ListOptions) (result *v1beta1.CSINodeList, err error) { - defer func() { +func (c *cSINodes) List(ctx context.Context, opts v1.ListOptions) (*v1beta1.CSINodeList, error) { + if watchListOptions, hasWatchListOptionsPrepared, watchListOptionsErr := watchlist.PrepareWatchListOptionsFromListOptions(opts); watchListOptionsErr != nil { + klog.Warningf("Failed preparing watchlist options for csinodes, falling back to the standard LIST semantics, err = %v", watchListOptionsErr) + } else if hasWatchListOptionsPrepared { + result, err := c.watchList(ctx, watchListOptions) if err == nil { - consistencydetector.CheckListFromCacheDataConsistencyIfRequested(ctx, "list request for csinodes", c.list, opts, result) + consistencydetector.CheckWatchListFromCacheDataConsistencyIfRequested(ctx, "watchlist request for csinodes", c.list, opts, result) + return result, nil } - }() - return c.list(ctx, opts) + klog.Warningf("The watchlist request for csinodes ended with an error, falling back to the standard LIST semantics, err = %v", err) + } + result, err := c.list(ctx, opts) + if err == nil { + consistencydetector.CheckListFromCacheDataConsistencyIfRequested(ctx, "list request for csinodes", c.list, opts, result) + } + return result, err } // list takes label and field selectors, and returns the list of CSINodes that match those selectors. @@ -104,6 +115,22 @@ func (c *cSINodes) list(ctx context.Context, opts v1.ListOptions) (result *v1bet return } +// watchList establishes a watch stream with the server and returns the list of CSINodes +func (c *cSINodes) watchList(ctx context.Context, opts v1.ListOptions) (result *v1beta1.CSINodeList, err error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + result = &v1beta1.CSINodeList{} + err = c.client.Get(). + Resource("csinodes"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + WatchList(ctx). + Into(result) + return +} + // Watch returns a watch.Interface that watches the requested cSINodes. func (c *cSINodes) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { var timeout time.Duration diff --git a/staging/src/k8s.io/client-go/kubernetes/typed/storage/v1beta1/csistoragecapacity.go b/staging/src/k8s.io/client-go/kubernetes/typed/storage/v1beta1/csistoragecapacity.go index eb4e044556e..a001e70ef42 100644 --- a/staging/src/k8s.io/client-go/kubernetes/typed/storage/v1beta1/csistoragecapacity.go +++ b/staging/src/k8s.io/client-go/kubernetes/typed/storage/v1beta1/csistoragecapacity.go @@ -32,6 +32,8 @@ import ( scheme "k8s.io/client-go/kubernetes/scheme" rest "k8s.io/client-go/rest" consistencydetector "k8s.io/client-go/util/consistencydetector" + watchlist "k8s.io/client-go/util/watchlist" + "k8s.io/klog/v2" ) // CSIStorageCapacitiesGetter has a method to return a CSIStorageCapacityInterface. @@ -82,13 +84,22 @@ func (c *cSIStorageCapacities) Get(ctx context.Context, name string, options v1. } // List takes label and field selectors, and returns the list of CSIStorageCapacities that match those selectors. -func (c *cSIStorageCapacities) List(ctx context.Context, opts v1.ListOptions) (result *v1beta1.CSIStorageCapacityList, err error) { - defer func() { +func (c *cSIStorageCapacities) List(ctx context.Context, opts v1.ListOptions) (*v1beta1.CSIStorageCapacityList, error) { + if watchListOptions, hasWatchListOptionsPrepared, watchListOptionsErr := watchlist.PrepareWatchListOptionsFromListOptions(opts); watchListOptionsErr != nil { + klog.Warningf("Failed preparing watchlist options for csistoragecapacities, falling back to the standard LIST semantics, err = %v", watchListOptionsErr) + } else if hasWatchListOptionsPrepared { + result, err := c.watchList(ctx, watchListOptions) if err == nil { - consistencydetector.CheckListFromCacheDataConsistencyIfRequested(ctx, "list request for csistoragecapacities", c.list, opts, result) + consistencydetector.CheckWatchListFromCacheDataConsistencyIfRequested(ctx, "watchlist request for csistoragecapacities", c.list, opts, result) + return result, nil } - }() - return c.list(ctx, opts) + klog.Warningf("The watchlist request for csistoragecapacities ended with an error, falling back to the standard LIST semantics, err = %v", err) + } + result, err := c.list(ctx, opts) + if err == nil { + consistencydetector.CheckListFromCacheDataConsistencyIfRequested(ctx, "list request for csistoragecapacities", c.list, opts, result) + } + return result, err } // list takes label and field selectors, and returns the list of CSIStorageCapacities that match those selectors. @@ -108,6 +119,23 @@ func (c *cSIStorageCapacities) list(ctx context.Context, opts v1.ListOptions) (r return } +// watchList establishes a watch stream with the server and returns the list of CSIStorageCapacities +func (c *cSIStorageCapacities) watchList(ctx context.Context, opts v1.ListOptions) (result *v1beta1.CSIStorageCapacityList, err error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + result = &v1beta1.CSIStorageCapacityList{} + err = c.client.Get(). + Namespace(c.ns). + Resource("csistoragecapacities"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + WatchList(ctx). + Into(result) + return +} + // Watch returns a watch.Interface that watches the requested cSIStorageCapacities. func (c *cSIStorageCapacities) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { var timeout time.Duration diff --git a/staging/src/k8s.io/client-go/kubernetes/typed/storage/v1beta1/storageclass.go b/staging/src/k8s.io/client-go/kubernetes/typed/storage/v1beta1/storageclass.go index b38a78db6cb..4a896348279 100644 --- a/staging/src/k8s.io/client-go/kubernetes/typed/storage/v1beta1/storageclass.go +++ b/staging/src/k8s.io/client-go/kubernetes/typed/storage/v1beta1/storageclass.go @@ -32,6 +32,8 @@ import ( scheme "k8s.io/client-go/kubernetes/scheme" rest "k8s.io/client-go/rest" consistencydetector "k8s.io/client-go/util/consistencydetector" + watchlist "k8s.io/client-go/util/watchlist" + "k8s.io/klog/v2" ) // StorageClassesGetter has a method to return a StorageClassInterface. @@ -79,13 +81,22 @@ func (c *storageClasses) Get(ctx context.Context, name string, options v1.GetOpt } // List takes label and field selectors, and returns the list of StorageClasses that match those selectors. -func (c *storageClasses) List(ctx context.Context, opts v1.ListOptions) (result *v1beta1.StorageClassList, err error) { - defer func() { +func (c *storageClasses) List(ctx context.Context, opts v1.ListOptions) (*v1beta1.StorageClassList, error) { + if watchListOptions, hasWatchListOptionsPrepared, watchListOptionsErr := watchlist.PrepareWatchListOptionsFromListOptions(opts); watchListOptionsErr != nil { + klog.Warningf("Failed preparing watchlist options for storageclasses, falling back to the standard LIST semantics, err = %v", watchListOptionsErr) + } else if hasWatchListOptionsPrepared { + result, err := c.watchList(ctx, watchListOptions) if err == nil { - consistencydetector.CheckListFromCacheDataConsistencyIfRequested(ctx, "list request for storageclasses", c.list, opts, result) + consistencydetector.CheckWatchListFromCacheDataConsistencyIfRequested(ctx, "watchlist request for storageclasses", c.list, opts, result) + return result, nil } - }() - return c.list(ctx, opts) + klog.Warningf("The watchlist request for storageclasses ended with an error, falling back to the standard LIST semantics, err = %v", err) + } + result, err := c.list(ctx, opts) + if err == nil { + consistencydetector.CheckListFromCacheDataConsistencyIfRequested(ctx, "list request for storageclasses", c.list, opts, result) + } + return result, err } // list takes label and field selectors, and returns the list of StorageClasses that match those selectors. @@ -104,6 +115,22 @@ func (c *storageClasses) list(ctx context.Context, opts v1.ListOptions) (result return } +// watchList establishes a watch stream with the server and returns the list of StorageClasses +func (c *storageClasses) watchList(ctx context.Context, opts v1.ListOptions) (result *v1beta1.StorageClassList, err error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + result = &v1beta1.StorageClassList{} + err = c.client.Get(). + Resource("storageclasses"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + WatchList(ctx). + Into(result) + return +} + // Watch returns a watch.Interface that watches the requested storageClasses. func (c *storageClasses) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { var timeout time.Duration diff --git a/staging/src/k8s.io/client-go/kubernetes/typed/storage/v1beta1/volumeattachment.go b/staging/src/k8s.io/client-go/kubernetes/typed/storage/v1beta1/volumeattachment.go index e82276772c0..0492a7a1634 100644 --- a/staging/src/k8s.io/client-go/kubernetes/typed/storage/v1beta1/volumeattachment.go +++ b/staging/src/k8s.io/client-go/kubernetes/typed/storage/v1beta1/volumeattachment.go @@ -32,6 +32,8 @@ import ( scheme "k8s.io/client-go/kubernetes/scheme" rest "k8s.io/client-go/rest" consistencydetector "k8s.io/client-go/util/consistencydetector" + watchlist "k8s.io/client-go/util/watchlist" + "k8s.io/klog/v2" ) // VolumeAttachmentsGetter has a method to return a VolumeAttachmentInterface. @@ -81,13 +83,22 @@ func (c *volumeAttachments) Get(ctx context.Context, name string, options v1.Get } // List takes label and field selectors, and returns the list of VolumeAttachments that match those selectors. -func (c *volumeAttachments) List(ctx context.Context, opts v1.ListOptions) (result *v1beta1.VolumeAttachmentList, err error) { - defer func() { +func (c *volumeAttachments) List(ctx context.Context, opts v1.ListOptions) (*v1beta1.VolumeAttachmentList, error) { + if watchListOptions, hasWatchListOptionsPrepared, watchListOptionsErr := watchlist.PrepareWatchListOptionsFromListOptions(opts); watchListOptionsErr != nil { + klog.Warningf("Failed preparing watchlist options for volumeattachments, falling back to the standard LIST semantics, err = %v", watchListOptionsErr) + } else if hasWatchListOptionsPrepared { + result, err := c.watchList(ctx, watchListOptions) if err == nil { - consistencydetector.CheckListFromCacheDataConsistencyIfRequested(ctx, "list request for volumeattachments", c.list, opts, result) + consistencydetector.CheckWatchListFromCacheDataConsistencyIfRequested(ctx, "watchlist request for volumeattachments", c.list, opts, result) + return result, nil } - }() - return c.list(ctx, opts) + klog.Warningf("The watchlist request for volumeattachments ended with an error, falling back to the standard LIST semantics, err = %v", err) + } + result, err := c.list(ctx, opts) + if err == nil { + consistencydetector.CheckListFromCacheDataConsistencyIfRequested(ctx, "list request for volumeattachments", c.list, opts, result) + } + return result, err } // list takes label and field selectors, and returns the list of VolumeAttachments that match those selectors. @@ -106,6 +117,22 @@ func (c *volumeAttachments) list(ctx context.Context, opts v1.ListOptions) (resu return } +// watchList establishes a watch stream with the server and returns the list of VolumeAttachments +func (c *volumeAttachments) watchList(ctx context.Context, opts v1.ListOptions) (result *v1beta1.VolumeAttachmentList, err error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + result = &v1beta1.VolumeAttachmentList{} + err = c.client.Get(). + Resource("volumeattachments"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + WatchList(ctx). + Into(result) + return +} + // Watch returns a watch.Interface that watches the requested volumeAttachments. func (c *volumeAttachments) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { var timeout time.Duration diff --git a/staging/src/k8s.io/client-go/kubernetes/typed/storagemigration/v1alpha1/storageversionmigration.go b/staging/src/k8s.io/client-go/kubernetes/typed/storagemigration/v1alpha1/storageversionmigration.go index 17fe4ac2ee4..5b9356f9cab 100644 --- a/staging/src/k8s.io/client-go/kubernetes/typed/storagemigration/v1alpha1/storageversionmigration.go +++ b/staging/src/k8s.io/client-go/kubernetes/typed/storagemigration/v1alpha1/storageversionmigration.go @@ -32,6 +32,8 @@ import ( scheme "k8s.io/client-go/kubernetes/scheme" rest "k8s.io/client-go/rest" consistencydetector "k8s.io/client-go/util/consistencydetector" + watchlist "k8s.io/client-go/util/watchlist" + "k8s.io/klog/v2" ) // StorageVersionMigrationsGetter has a method to return a StorageVersionMigrationInterface. @@ -81,13 +83,22 @@ func (c *storageVersionMigrations) Get(ctx context.Context, name string, options } // List takes label and field selectors, and returns the list of StorageVersionMigrations that match those selectors. -func (c *storageVersionMigrations) List(ctx context.Context, opts v1.ListOptions) (result *v1alpha1.StorageVersionMigrationList, err error) { - defer func() { +func (c *storageVersionMigrations) List(ctx context.Context, opts v1.ListOptions) (*v1alpha1.StorageVersionMigrationList, error) { + if watchListOptions, hasWatchListOptionsPrepared, watchListOptionsErr := watchlist.PrepareWatchListOptionsFromListOptions(opts); watchListOptionsErr != nil { + klog.Warningf("Failed preparing watchlist options for storageversionmigrations, falling back to the standard LIST semantics, err = %v", watchListOptionsErr) + } else if hasWatchListOptionsPrepared { + result, err := c.watchList(ctx, watchListOptions) if err == nil { - consistencydetector.CheckListFromCacheDataConsistencyIfRequested(ctx, "list request for storageversionmigrations", c.list, opts, result) + consistencydetector.CheckWatchListFromCacheDataConsistencyIfRequested(ctx, "watchlist request for storageversionmigrations", c.list, opts, result) + return result, nil } - }() - return c.list(ctx, opts) + klog.Warningf("The watchlist request for storageversionmigrations ended with an error, falling back to the standard LIST semantics, err = %v", err) + } + result, err := c.list(ctx, opts) + if err == nil { + consistencydetector.CheckListFromCacheDataConsistencyIfRequested(ctx, "list request for storageversionmigrations", c.list, opts, result) + } + return result, err } // list takes label and field selectors, and returns the list of StorageVersionMigrations that match those selectors. @@ -106,6 +117,22 @@ func (c *storageVersionMigrations) list(ctx context.Context, opts v1.ListOptions return } +// watchList establishes a watch stream with the server and returns the list of StorageVersionMigrations +func (c *storageVersionMigrations) watchList(ctx context.Context, opts v1.ListOptions) (result *v1alpha1.StorageVersionMigrationList, err error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + result = &v1alpha1.StorageVersionMigrationList{} + err = c.client.Get(). + Resource("storageversionmigrations"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + WatchList(ctx). + Into(result) + return +} + // Watch returns a watch.Interface that watches the requested storageVersionMigrations. func (c *storageVersionMigrations) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { var timeout time.Duration diff --git a/staging/src/k8s.io/code-generator/examples/HyphenGroup/clientset/versioned/typed/example/v1/clustertesttype.go b/staging/src/k8s.io/code-generator/examples/HyphenGroup/clientset/versioned/typed/example/v1/clustertesttype.go index dcdc5277279..54ac7c21cb5 100644 --- a/staging/src/k8s.io/code-generator/examples/HyphenGroup/clientset/versioned/typed/example/v1/clustertesttype.go +++ b/staging/src/k8s.io/code-generator/examples/HyphenGroup/clientset/versioned/typed/example/v1/clustertesttype.go @@ -30,9 +30,11 @@ import ( watch "k8s.io/apimachinery/pkg/watch" rest "k8s.io/client-go/rest" consistencydetector "k8s.io/client-go/util/consistencydetector" + watchlist "k8s.io/client-go/util/watchlist" v1 "k8s.io/code-generator/examples/HyphenGroup/apis/example/v1" examplev1 "k8s.io/code-generator/examples/HyphenGroup/applyconfiguration/example/v1" scheme "k8s.io/code-generator/examples/HyphenGroup/clientset/versioned/scheme" + "k8s.io/klog/v2" ) // ClusterTestTypesGetter has a method to return a ClusterTestTypeInterface. @@ -85,13 +87,22 @@ func (c *clusterTestTypes) Get(ctx context.Context, name string, options metav1. } // List takes label and field selectors, and returns the list of ClusterTestTypes that match those selectors. -func (c *clusterTestTypes) List(ctx context.Context, opts metav1.ListOptions) (result *v1.ClusterTestTypeList, err error) { - defer func() { +func (c *clusterTestTypes) List(ctx context.Context, opts metav1.ListOptions) (*v1.ClusterTestTypeList, error) { + if watchListOptions, hasWatchListOptionsPrepared, watchListOptionsErr := watchlist.PrepareWatchListOptionsFromListOptions(opts); watchListOptionsErr != nil { + klog.Warningf("Failed preparing watchlist options for clustertesttypes, falling back to the standard LIST semantics, err = %v", watchListOptionsErr) + } else if hasWatchListOptionsPrepared { + result, err := c.watchList(ctx, watchListOptions) if err == nil { - consistencydetector.CheckListFromCacheDataConsistencyIfRequested(ctx, "list request for clustertesttypes", c.list, opts, result) + consistencydetector.CheckWatchListFromCacheDataConsistencyIfRequested(ctx, "watchlist request for clustertesttypes", c.list, opts, result) + return result, nil } - }() - return c.list(ctx, opts) + klog.Warningf("The watchlist request for clustertesttypes ended with an error, falling back to the standard LIST semantics, err = %v", err) + } + result, err := c.list(ctx, opts) + if err == nil { + consistencydetector.CheckListFromCacheDataConsistencyIfRequested(ctx, "list request for clustertesttypes", c.list, opts, result) + } + return result, err } // list takes label and field selectors, and returns the list of ClusterTestTypes that match those selectors. @@ -110,6 +121,22 @@ func (c *clusterTestTypes) list(ctx context.Context, opts metav1.ListOptions) (r return } +// watchList establishes a watch stream with the server and returns the list of ClusterTestTypes +func (c *clusterTestTypes) watchList(ctx context.Context, opts metav1.ListOptions) (result *v1.ClusterTestTypeList, err error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + result = &v1.ClusterTestTypeList{} + err = c.client.Get(). + Resource("clustertesttypes"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + WatchList(ctx). + Into(result) + return +} + // Watch returns a watch.Interface that watches the requested clusterTestTypes. func (c *clusterTestTypes) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { var timeout time.Duration diff --git a/staging/src/k8s.io/code-generator/examples/HyphenGroup/clientset/versioned/typed/example/v1/testtype.go b/staging/src/k8s.io/code-generator/examples/HyphenGroup/clientset/versioned/typed/example/v1/testtype.go index 159898a2599..789c1867b6f 100644 --- a/staging/src/k8s.io/code-generator/examples/HyphenGroup/clientset/versioned/typed/example/v1/testtype.go +++ b/staging/src/k8s.io/code-generator/examples/HyphenGroup/clientset/versioned/typed/example/v1/testtype.go @@ -29,9 +29,11 @@ import ( watch "k8s.io/apimachinery/pkg/watch" rest "k8s.io/client-go/rest" consistencydetector "k8s.io/client-go/util/consistencydetector" + watchlist "k8s.io/client-go/util/watchlist" v1 "k8s.io/code-generator/examples/HyphenGroup/apis/example/v1" examplev1 "k8s.io/code-generator/examples/HyphenGroup/applyconfiguration/example/v1" scheme "k8s.io/code-generator/examples/HyphenGroup/clientset/versioned/scheme" + "k8s.io/klog/v2" ) // TestTypesGetter has a method to return a TestTypeInterface. @@ -84,13 +86,22 @@ func (c *testTypes) Get(ctx context.Context, name string, options metav1.GetOpti } // List takes label and field selectors, and returns the list of TestTypes that match those selectors. -func (c *testTypes) List(ctx context.Context, opts metav1.ListOptions) (result *v1.TestTypeList, err error) { - defer func() { +func (c *testTypes) List(ctx context.Context, opts metav1.ListOptions) (*v1.TestTypeList, error) { + if watchListOptions, hasWatchListOptionsPrepared, watchListOptionsErr := watchlist.PrepareWatchListOptionsFromListOptions(opts); watchListOptionsErr != nil { + klog.Warningf("Failed preparing watchlist options for testtypes, falling back to the standard LIST semantics, err = %v", watchListOptionsErr) + } else if hasWatchListOptionsPrepared { + result, err := c.watchList(ctx, watchListOptions) if err == nil { - consistencydetector.CheckListFromCacheDataConsistencyIfRequested(ctx, "list request for testtypes", c.list, opts, result) + consistencydetector.CheckWatchListFromCacheDataConsistencyIfRequested(ctx, "watchlist request for testtypes", c.list, opts, result) + return result, nil } - }() - return c.list(ctx, opts) + klog.Warningf("The watchlist request for testtypes ended with an error, falling back to the standard LIST semantics, err = %v", err) + } + result, err := c.list(ctx, opts) + if err == nil { + consistencydetector.CheckListFromCacheDataConsistencyIfRequested(ctx, "list request for testtypes", c.list, opts, result) + } + return result, err } // list takes label and field selectors, and returns the list of TestTypes that match those selectors. @@ -110,6 +121,23 @@ func (c *testTypes) list(ctx context.Context, opts metav1.ListOptions) (result * return } +// watchList establishes a watch stream with the server and returns the list of TestTypes +func (c *testTypes) watchList(ctx context.Context, opts metav1.ListOptions) (result *v1.TestTypeList, err error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + result = &v1.TestTypeList{} + err = c.client.Get(). + Namespace(c.ns). + Resource("testtypes"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + WatchList(ctx). + Into(result) + return +} + // Watch returns a watch.Interface that watches the requested testTypes. func (c *testTypes) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { var timeout time.Duration diff --git a/staging/src/k8s.io/code-generator/examples/MixedCase/clientset/versioned/typed/example/v1/clustertesttype.go b/staging/src/k8s.io/code-generator/examples/MixedCase/clientset/versioned/typed/example/v1/clustertesttype.go index e545083f425..9041b8d94e1 100644 --- a/staging/src/k8s.io/code-generator/examples/MixedCase/clientset/versioned/typed/example/v1/clustertesttype.go +++ b/staging/src/k8s.io/code-generator/examples/MixedCase/clientset/versioned/typed/example/v1/clustertesttype.go @@ -30,9 +30,11 @@ import ( watch "k8s.io/apimachinery/pkg/watch" rest "k8s.io/client-go/rest" consistencydetector "k8s.io/client-go/util/consistencydetector" + watchlist "k8s.io/client-go/util/watchlist" v1 "k8s.io/code-generator/examples/MixedCase/apis/example/v1" examplev1 "k8s.io/code-generator/examples/MixedCase/applyconfiguration/example/v1" scheme "k8s.io/code-generator/examples/MixedCase/clientset/versioned/scheme" + "k8s.io/klog/v2" ) // ClusterTestTypesGetter has a method to return a ClusterTestTypeInterface. @@ -86,13 +88,22 @@ func (c *clusterTestTypes) Get(ctx context.Context, name string, options metav1. } // List takes label and field selectors, and returns the list of ClusterTestTypes that match those selectors. -func (c *clusterTestTypes) List(ctx context.Context, opts metav1.ListOptions) (result *v1.ClusterTestTypeList, err error) { - defer func() { +func (c *clusterTestTypes) List(ctx context.Context, opts metav1.ListOptions) (*v1.ClusterTestTypeList, error) { + if watchListOptions, hasWatchListOptionsPrepared, watchListOptionsErr := watchlist.PrepareWatchListOptionsFromListOptions(opts); watchListOptionsErr != nil { + klog.Warningf("Failed preparing watchlist options for clustertesttypes, falling back to the standard LIST semantics, err = %v", watchListOptionsErr) + } else if hasWatchListOptionsPrepared { + result, err := c.watchList(ctx, watchListOptions) if err == nil { - consistencydetector.CheckListFromCacheDataConsistencyIfRequested(ctx, "list request for clustertesttypes", c.list, opts, result) + consistencydetector.CheckWatchListFromCacheDataConsistencyIfRequested(ctx, "watchlist request for clustertesttypes", c.list, opts, result) + return result, nil } - }() - return c.list(ctx, opts) + klog.Warningf("The watchlist request for clustertesttypes ended with an error, falling back to the standard LIST semantics, err = %v", err) + } + result, err := c.list(ctx, opts) + if err == nil { + consistencydetector.CheckListFromCacheDataConsistencyIfRequested(ctx, "list request for clustertesttypes", c.list, opts, result) + } + return result, err } // list takes label and field selectors, and returns the list of ClusterTestTypes that match those selectors. @@ -111,6 +122,22 @@ func (c *clusterTestTypes) list(ctx context.Context, opts metav1.ListOptions) (r return } +// watchList establishes a watch stream with the server and returns the list of ClusterTestTypes +func (c *clusterTestTypes) watchList(ctx context.Context, opts metav1.ListOptions) (result *v1.ClusterTestTypeList, err error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + result = &v1.ClusterTestTypeList{} + err = c.client.Get(). + Resource("clustertesttypes"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + WatchList(ctx). + Into(result) + return +} + // Watch returns a watch.Interface that watches the requested clusterTestTypes. func (c *clusterTestTypes) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { var timeout time.Duration diff --git a/staging/src/k8s.io/code-generator/examples/MixedCase/clientset/versioned/typed/example/v1/testtype.go b/staging/src/k8s.io/code-generator/examples/MixedCase/clientset/versioned/typed/example/v1/testtype.go index cdc50114037..85643f95d06 100644 --- a/staging/src/k8s.io/code-generator/examples/MixedCase/clientset/versioned/typed/example/v1/testtype.go +++ b/staging/src/k8s.io/code-generator/examples/MixedCase/clientset/versioned/typed/example/v1/testtype.go @@ -29,9 +29,11 @@ import ( watch "k8s.io/apimachinery/pkg/watch" rest "k8s.io/client-go/rest" consistencydetector "k8s.io/client-go/util/consistencydetector" + watchlist "k8s.io/client-go/util/watchlist" v1 "k8s.io/code-generator/examples/MixedCase/apis/example/v1" examplev1 "k8s.io/code-generator/examples/MixedCase/applyconfiguration/example/v1" scheme "k8s.io/code-generator/examples/MixedCase/clientset/versioned/scheme" + "k8s.io/klog/v2" ) // TestTypesGetter has a method to return a TestTypeInterface. @@ -84,13 +86,22 @@ func (c *testTypes) Get(ctx context.Context, name string, options metav1.GetOpti } // List takes label and field selectors, and returns the list of TestTypes that match those selectors. -func (c *testTypes) List(ctx context.Context, opts metav1.ListOptions) (result *v1.TestTypeList, err error) { - defer func() { +func (c *testTypes) List(ctx context.Context, opts metav1.ListOptions) (*v1.TestTypeList, error) { + if watchListOptions, hasWatchListOptionsPrepared, watchListOptionsErr := watchlist.PrepareWatchListOptionsFromListOptions(opts); watchListOptionsErr != nil { + klog.Warningf("Failed preparing watchlist options for testtypes, falling back to the standard LIST semantics, err = %v", watchListOptionsErr) + } else if hasWatchListOptionsPrepared { + result, err := c.watchList(ctx, watchListOptions) if err == nil { - consistencydetector.CheckListFromCacheDataConsistencyIfRequested(ctx, "list request for testtypes", c.list, opts, result) + consistencydetector.CheckWatchListFromCacheDataConsistencyIfRequested(ctx, "watchlist request for testtypes", c.list, opts, result) + return result, nil } - }() - return c.list(ctx, opts) + klog.Warningf("The watchlist request for testtypes ended with an error, falling back to the standard LIST semantics, err = %v", err) + } + result, err := c.list(ctx, opts) + if err == nil { + consistencydetector.CheckListFromCacheDataConsistencyIfRequested(ctx, "list request for testtypes", c.list, opts, result) + } + return result, err } // list takes label and field selectors, and returns the list of TestTypes that match those selectors. @@ -110,6 +121,23 @@ func (c *testTypes) list(ctx context.Context, opts metav1.ListOptions) (result * return } +// watchList establishes a watch stream with the server and returns the list of TestTypes +func (c *testTypes) watchList(ctx context.Context, opts metav1.ListOptions) (result *v1.TestTypeList, err error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + result = &v1.TestTypeList{} + err = c.client.Get(). + Namespace(c.ns). + Resource("testtypes"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + WatchList(ctx). + Into(result) + return +} + // Watch returns a watch.Interface that watches the requested testTypes. func (c *testTypes) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { var timeout time.Duration diff --git a/staging/src/k8s.io/code-generator/examples/apiserver/clientset/versioned/typed/example/v1/testtype.go b/staging/src/k8s.io/code-generator/examples/apiserver/clientset/versioned/typed/example/v1/testtype.go index e0e3712febe..c2dcd753e71 100644 --- a/staging/src/k8s.io/code-generator/examples/apiserver/clientset/versioned/typed/example/v1/testtype.go +++ b/staging/src/k8s.io/code-generator/examples/apiserver/clientset/versioned/typed/example/v1/testtype.go @@ -27,8 +27,10 @@ import ( watch "k8s.io/apimachinery/pkg/watch" rest "k8s.io/client-go/rest" consistencydetector "k8s.io/client-go/util/consistencydetector" + watchlist "k8s.io/client-go/util/watchlist" v1 "k8s.io/code-generator/examples/apiserver/apis/example/v1" scheme "k8s.io/code-generator/examples/apiserver/clientset/versioned/scheme" + "k8s.io/klog/v2" ) // TestTypesGetter has a method to return a TestTypeInterface. @@ -79,13 +81,22 @@ func (c *testTypes) Get(ctx context.Context, name string, options metav1.GetOpti } // List takes label and field selectors, and returns the list of TestTypes that match those selectors. -func (c *testTypes) List(ctx context.Context, opts metav1.ListOptions) (result *v1.TestTypeList, err error) { - defer func() { +func (c *testTypes) List(ctx context.Context, opts metav1.ListOptions) (*v1.TestTypeList, error) { + if watchListOptions, hasWatchListOptionsPrepared, watchListOptionsErr := watchlist.PrepareWatchListOptionsFromListOptions(opts); watchListOptionsErr != nil { + klog.Warningf("Failed preparing watchlist options for testtypes, falling back to the standard LIST semantics, err = %v", watchListOptionsErr) + } else if hasWatchListOptionsPrepared { + result, err := c.watchList(ctx, watchListOptions) if err == nil { - consistencydetector.CheckListFromCacheDataConsistencyIfRequested(ctx, "list request for testtypes", c.list, opts, result) + consistencydetector.CheckWatchListFromCacheDataConsistencyIfRequested(ctx, "watchlist request for testtypes", c.list, opts, result) + return result, nil } - }() - return c.list(ctx, opts) + klog.Warningf("The watchlist request for testtypes ended with an error, falling back to the standard LIST semantics, err = %v", err) + } + result, err := c.list(ctx, opts) + if err == nil { + consistencydetector.CheckListFromCacheDataConsistencyIfRequested(ctx, "list request for testtypes", c.list, opts, result) + } + return result, err } // list takes label and field selectors, and returns the list of TestTypes that match those selectors. @@ -105,6 +116,23 @@ func (c *testTypes) list(ctx context.Context, opts metav1.ListOptions) (result * return } +// watchList establishes a watch stream with the server and returns the list of TestTypes +func (c *testTypes) watchList(ctx context.Context, opts metav1.ListOptions) (result *v1.TestTypeList, err error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + result = &v1.TestTypeList{} + err = c.client.Get(). + Namespace(c.ns). + Resource("testtypes"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + WatchList(ctx). + Into(result) + return +} + // Watch returns a watch.Interface that watches the requested testTypes. func (c *testTypes) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { var timeout time.Duration diff --git a/staging/src/k8s.io/code-generator/examples/apiserver/clientset/versioned/typed/example2/v1/testtype.go b/staging/src/k8s.io/code-generator/examples/apiserver/clientset/versioned/typed/example2/v1/testtype.go index 792855c3ae2..51d26bdb10e 100644 --- a/staging/src/k8s.io/code-generator/examples/apiserver/clientset/versioned/typed/example2/v1/testtype.go +++ b/staging/src/k8s.io/code-generator/examples/apiserver/clientset/versioned/typed/example2/v1/testtype.go @@ -27,8 +27,10 @@ import ( watch "k8s.io/apimachinery/pkg/watch" rest "k8s.io/client-go/rest" consistencydetector "k8s.io/client-go/util/consistencydetector" + watchlist "k8s.io/client-go/util/watchlist" v1 "k8s.io/code-generator/examples/apiserver/apis/example2/v1" scheme "k8s.io/code-generator/examples/apiserver/clientset/versioned/scheme" + "k8s.io/klog/v2" ) // TestTypesGetter has a method to return a TestTypeInterface. @@ -79,13 +81,22 @@ func (c *testTypes) Get(ctx context.Context, name string, options metav1.GetOpti } // List takes label and field selectors, and returns the list of TestTypes that match those selectors. -func (c *testTypes) List(ctx context.Context, opts metav1.ListOptions) (result *v1.TestTypeList, err error) { - defer func() { +func (c *testTypes) List(ctx context.Context, opts metav1.ListOptions) (*v1.TestTypeList, error) { + if watchListOptions, hasWatchListOptionsPrepared, watchListOptionsErr := watchlist.PrepareWatchListOptionsFromListOptions(opts); watchListOptionsErr != nil { + klog.Warningf("Failed preparing watchlist options for testtypes, falling back to the standard LIST semantics, err = %v", watchListOptionsErr) + } else if hasWatchListOptionsPrepared { + result, err := c.watchList(ctx, watchListOptions) if err == nil { - consistencydetector.CheckListFromCacheDataConsistencyIfRequested(ctx, "list request for testtypes", c.list, opts, result) + consistencydetector.CheckWatchListFromCacheDataConsistencyIfRequested(ctx, "watchlist request for testtypes", c.list, opts, result) + return result, nil } - }() - return c.list(ctx, opts) + klog.Warningf("The watchlist request for testtypes ended with an error, falling back to the standard LIST semantics, err = %v", err) + } + result, err := c.list(ctx, opts) + if err == nil { + consistencydetector.CheckListFromCacheDataConsistencyIfRequested(ctx, "list request for testtypes", c.list, opts, result) + } + return result, err } // list takes label and field selectors, and returns the list of TestTypes that match those selectors. @@ -105,6 +116,23 @@ func (c *testTypes) list(ctx context.Context, opts metav1.ListOptions) (result * return } +// watchList establishes a watch stream with the server and returns the list of TestTypes +func (c *testTypes) watchList(ctx context.Context, opts metav1.ListOptions) (result *v1.TestTypeList, err error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + result = &v1.TestTypeList{} + err = c.client.Get(). + Namespace(c.ns). + Resource("testtypes"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + WatchList(ctx). + Into(result) + return +} + // Watch returns a watch.Interface that watches the requested testTypes. func (c *testTypes) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { var timeout time.Duration diff --git a/staging/src/k8s.io/code-generator/examples/apiserver/clientset/versioned/typed/example3.io/v1/testtype.go b/staging/src/k8s.io/code-generator/examples/apiserver/clientset/versioned/typed/example3.io/v1/testtype.go index dabc3780d95..a7076c3f382 100644 --- a/staging/src/k8s.io/code-generator/examples/apiserver/clientset/versioned/typed/example3.io/v1/testtype.go +++ b/staging/src/k8s.io/code-generator/examples/apiserver/clientset/versioned/typed/example3.io/v1/testtype.go @@ -27,8 +27,10 @@ import ( watch "k8s.io/apimachinery/pkg/watch" rest "k8s.io/client-go/rest" consistencydetector "k8s.io/client-go/util/consistencydetector" + watchlist "k8s.io/client-go/util/watchlist" v1 "k8s.io/code-generator/examples/apiserver/apis/example3.io/v1" scheme "k8s.io/code-generator/examples/apiserver/clientset/versioned/scheme" + "k8s.io/klog/v2" ) // TestTypesGetter has a method to return a TestTypeInterface. @@ -79,13 +81,22 @@ func (c *testTypes) Get(ctx context.Context, name string, options metav1.GetOpti } // List takes label and field selectors, and returns the list of TestTypes that match those selectors. -func (c *testTypes) List(ctx context.Context, opts metav1.ListOptions) (result *v1.TestTypeList, err error) { - defer func() { +func (c *testTypes) List(ctx context.Context, opts metav1.ListOptions) (*v1.TestTypeList, error) { + if watchListOptions, hasWatchListOptionsPrepared, watchListOptionsErr := watchlist.PrepareWatchListOptionsFromListOptions(opts); watchListOptionsErr != nil { + klog.Warningf("Failed preparing watchlist options for testtypes, falling back to the standard LIST semantics, err = %v", watchListOptionsErr) + } else if hasWatchListOptionsPrepared { + result, err := c.watchList(ctx, watchListOptions) if err == nil { - consistencydetector.CheckListFromCacheDataConsistencyIfRequested(ctx, "list request for testtypes", c.list, opts, result) + consistencydetector.CheckWatchListFromCacheDataConsistencyIfRequested(ctx, "watchlist request for testtypes", c.list, opts, result) + return result, nil } - }() - return c.list(ctx, opts) + klog.Warningf("The watchlist request for testtypes ended with an error, falling back to the standard LIST semantics, err = %v", err) + } + result, err := c.list(ctx, opts) + if err == nil { + consistencydetector.CheckListFromCacheDataConsistencyIfRequested(ctx, "list request for testtypes", c.list, opts, result) + } + return result, err } // list takes label and field selectors, and returns the list of TestTypes that match those selectors. @@ -105,6 +116,23 @@ func (c *testTypes) list(ctx context.Context, opts metav1.ListOptions) (result * return } +// watchList establishes a watch stream with the server and returns the list of TestTypes +func (c *testTypes) watchList(ctx context.Context, opts metav1.ListOptions) (result *v1.TestTypeList, err error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + result = &v1.TestTypeList{} + err = c.client.Get(). + Namespace(c.ns). + Resource("testtypes"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + WatchList(ctx). + Into(result) + return +} + // Watch returns a watch.Interface that watches the requested testTypes. func (c *testTypes) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { var timeout time.Duration diff --git a/staging/src/k8s.io/code-generator/examples/crd/clientset/versioned/typed/example/v1/clustertesttype.go b/staging/src/k8s.io/code-generator/examples/crd/clientset/versioned/typed/example/v1/clustertesttype.go index c7848650784..ce1ccf64d3d 100644 --- a/staging/src/k8s.io/code-generator/examples/crd/clientset/versioned/typed/example/v1/clustertesttype.go +++ b/staging/src/k8s.io/code-generator/examples/crd/clientset/versioned/typed/example/v1/clustertesttype.go @@ -30,9 +30,11 @@ import ( watch "k8s.io/apimachinery/pkg/watch" rest "k8s.io/client-go/rest" consistencydetector "k8s.io/client-go/util/consistencydetector" + watchlist "k8s.io/client-go/util/watchlist" v1 "k8s.io/code-generator/examples/crd/apis/example/v1" examplev1 "k8s.io/code-generator/examples/crd/applyconfiguration/example/v1" scheme "k8s.io/code-generator/examples/crd/clientset/versioned/scheme" + "k8s.io/klog/v2" ) // ClusterTestTypesGetter has a method to return a ClusterTestTypeInterface. @@ -85,13 +87,22 @@ func (c *clusterTestTypes) Get(ctx context.Context, name string, options metav1. } // List takes label and field selectors, and returns the list of ClusterTestTypes that match those selectors. -func (c *clusterTestTypes) List(ctx context.Context, opts metav1.ListOptions) (result *v1.ClusterTestTypeList, err error) { - defer func() { +func (c *clusterTestTypes) List(ctx context.Context, opts metav1.ListOptions) (*v1.ClusterTestTypeList, error) { + if watchListOptions, hasWatchListOptionsPrepared, watchListOptionsErr := watchlist.PrepareWatchListOptionsFromListOptions(opts); watchListOptionsErr != nil { + klog.Warningf("Failed preparing watchlist options for clustertesttypes, falling back to the standard LIST semantics, err = %v", watchListOptionsErr) + } else if hasWatchListOptionsPrepared { + result, err := c.watchList(ctx, watchListOptions) if err == nil { - consistencydetector.CheckListFromCacheDataConsistencyIfRequested(ctx, "list request for clustertesttypes", c.list, opts, result) + consistencydetector.CheckWatchListFromCacheDataConsistencyIfRequested(ctx, "watchlist request for clustertesttypes", c.list, opts, result) + return result, nil } - }() - return c.list(ctx, opts) + klog.Warningf("The watchlist request for clustertesttypes ended with an error, falling back to the standard LIST semantics, err = %v", err) + } + result, err := c.list(ctx, opts) + if err == nil { + consistencydetector.CheckListFromCacheDataConsistencyIfRequested(ctx, "list request for clustertesttypes", c.list, opts, result) + } + return result, err } // list takes label and field selectors, and returns the list of ClusterTestTypes that match those selectors. @@ -110,6 +121,22 @@ func (c *clusterTestTypes) list(ctx context.Context, opts metav1.ListOptions) (r return } +// watchList establishes a watch stream with the server and returns the list of ClusterTestTypes +func (c *clusterTestTypes) watchList(ctx context.Context, opts metav1.ListOptions) (result *v1.ClusterTestTypeList, err error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + result = &v1.ClusterTestTypeList{} + err = c.client.Get(). + Resource("clustertesttypes"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + WatchList(ctx). + Into(result) + return +} + // Watch returns a watch.Interface that watches the requested clusterTestTypes. func (c *clusterTestTypes) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { var timeout time.Duration diff --git a/staging/src/k8s.io/code-generator/examples/crd/clientset/versioned/typed/example/v1/testtype.go b/staging/src/k8s.io/code-generator/examples/crd/clientset/versioned/typed/example/v1/testtype.go index a084503e05a..e6c1e13f062 100644 --- a/staging/src/k8s.io/code-generator/examples/crd/clientset/versioned/typed/example/v1/testtype.go +++ b/staging/src/k8s.io/code-generator/examples/crd/clientset/versioned/typed/example/v1/testtype.go @@ -29,9 +29,11 @@ import ( watch "k8s.io/apimachinery/pkg/watch" rest "k8s.io/client-go/rest" consistencydetector "k8s.io/client-go/util/consistencydetector" + watchlist "k8s.io/client-go/util/watchlist" v1 "k8s.io/code-generator/examples/crd/apis/example/v1" examplev1 "k8s.io/code-generator/examples/crd/applyconfiguration/example/v1" scheme "k8s.io/code-generator/examples/crd/clientset/versioned/scheme" + "k8s.io/klog/v2" ) // TestTypesGetter has a method to return a TestTypeInterface. @@ -84,13 +86,22 @@ func (c *testTypes) Get(ctx context.Context, name string, options metav1.GetOpti } // List takes label and field selectors, and returns the list of TestTypes that match those selectors. -func (c *testTypes) List(ctx context.Context, opts metav1.ListOptions) (result *v1.TestTypeList, err error) { - defer func() { +func (c *testTypes) List(ctx context.Context, opts metav1.ListOptions) (*v1.TestTypeList, error) { + if watchListOptions, hasWatchListOptionsPrepared, watchListOptionsErr := watchlist.PrepareWatchListOptionsFromListOptions(opts); watchListOptionsErr != nil { + klog.Warningf("Failed preparing watchlist options for testtypes, falling back to the standard LIST semantics, err = %v", watchListOptionsErr) + } else if hasWatchListOptionsPrepared { + result, err := c.watchList(ctx, watchListOptions) if err == nil { - consistencydetector.CheckListFromCacheDataConsistencyIfRequested(ctx, "list request for testtypes", c.list, opts, result) + consistencydetector.CheckWatchListFromCacheDataConsistencyIfRequested(ctx, "watchlist request for testtypes", c.list, opts, result) + return result, nil } - }() - return c.list(ctx, opts) + klog.Warningf("The watchlist request for testtypes ended with an error, falling back to the standard LIST semantics, err = %v", err) + } + result, err := c.list(ctx, opts) + if err == nil { + consistencydetector.CheckListFromCacheDataConsistencyIfRequested(ctx, "list request for testtypes", c.list, opts, result) + } + return result, err } // list takes label and field selectors, and returns the list of TestTypes that match those selectors. @@ -110,6 +121,23 @@ func (c *testTypes) list(ctx context.Context, opts metav1.ListOptions) (result * return } +// watchList establishes a watch stream with the server and returns the list of TestTypes +func (c *testTypes) watchList(ctx context.Context, opts metav1.ListOptions) (result *v1.TestTypeList, err error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + result = &v1.TestTypeList{} + err = c.client.Get(). + Namespace(c.ns). + Resource("testtypes"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + WatchList(ctx). + Into(result) + return +} + // Watch returns a watch.Interface that watches the requested testTypes. func (c *testTypes) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { var timeout time.Duration diff --git a/staging/src/k8s.io/code-generator/examples/crd/clientset/versioned/typed/example2/v1/testtype.go b/staging/src/k8s.io/code-generator/examples/crd/clientset/versioned/typed/example2/v1/testtype.go index 2f05df5ff23..2675cbb3e56 100644 --- a/staging/src/k8s.io/code-generator/examples/crd/clientset/versioned/typed/example2/v1/testtype.go +++ b/staging/src/k8s.io/code-generator/examples/crd/clientset/versioned/typed/example2/v1/testtype.go @@ -29,9 +29,11 @@ import ( watch "k8s.io/apimachinery/pkg/watch" rest "k8s.io/client-go/rest" consistencydetector "k8s.io/client-go/util/consistencydetector" + watchlist "k8s.io/client-go/util/watchlist" v1 "k8s.io/code-generator/examples/crd/apis/example2/v1" example2v1 "k8s.io/code-generator/examples/crd/applyconfiguration/example2/v1" scheme "k8s.io/code-generator/examples/crd/clientset/versioned/scheme" + "k8s.io/klog/v2" ) // TestTypesGetter has a method to return a TestTypeInterface. @@ -84,13 +86,22 @@ func (c *testTypes) Get(ctx context.Context, name string, options metav1.GetOpti } // List takes label and field selectors, and returns the list of TestTypes that match those selectors. -func (c *testTypes) List(ctx context.Context, opts metav1.ListOptions) (result *v1.TestTypeList, err error) { - defer func() { +func (c *testTypes) List(ctx context.Context, opts metav1.ListOptions) (*v1.TestTypeList, error) { + if watchListOptions, hasWatchListOptionsPrepared, watchListOptionsErr := watchlist.PrepareWatchListOptionsFromListOptions(opts); watchListOptionsErr != nil { + klog.Warningf("Failed preparing watchlist options for testtypes, falling back to the standard LIST semantics, err = %v", watchListOptionsErr) + } else if hasWatchListOptionsPrepared { + result, err := c.watchList(ctx, watchListOptions) if err == nil { - consistencydetector.CheckListFromCacheDataConsistencyIfRequested(ctx, "list request for testtypes", c.list, opts, result) + consistencydetector.CheckWatchListFromCacheDataConsistencyIfRequested(ctx, "watchlist request for testtypes", c.list, opts, result) + return result, nil } - }() - return c.list(ctx, opts) + klog.Warningf("The watchlist request for testtypes ended with an error, falling back to the standard LIST semantics, err = %v", err) + } + result, err := c.list(ctx, opts) + if err == nil { + consistencydetector.CheckListFromCacheDataConsistencyIfRequested(ctx, "list request for testtypes", c.list, opts, result) + } + return result, err } // list takes label and field selectors, and returns the list of TestTypes that match those selectors. @@ -110,6 +121,23 @@ func (c *testTypes) list(ctx context.Context, opts metav1.ListOptions) (result * return } +// watchList establishes a watch stream with the server and returns the list of TestTypes +func (c *testTypes) watchList(ctx context.Context, opts metav1.ListOptions) (result *v1.TestTypeList, err error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + result = &v1.TestTypeList{} + err = c.client.Get(). + Namespace(c.ns). + Resource("testtypes"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + WatchList(ctx). + Into(result) + return +} + // Watch returns a watch.Interface that watches the requested testTypes. func (c *testTypes) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { var timeout time.Duration diff --git a/staging/src/k8s.io/kube-aggregator/pkg/client/clientset_generated/clientset/typed/apiregistration/v1/apiservice.go b/staging/src/k8s.io/kube-aggregator/pkg/client/clientset_generated/clientset/typed/apiregistration/v1/apiservice.go index de84130c139..62c2a791a59 100644 --- a/staging/src/k8s.io/kube-aggregator/pkg/client/clientset_generated/clientset/typed/apiregistration/v1/apiservice.go +++ b/staging/src/k8s.io/kube-aggregator/pkg/client/clientset_generated/clientset/typed/apiregistration/v1/apiservice.go @@ -27,6 +27,8 @@ import ( watch "k8s.io/apimachinery/pkg/watch" rest "k8s.io/client-go/rest" consistencydetector "k8s.io/client-go/util/consistencydetector" + watchlist "k8s.io/client-go/util/watchlist" + "k8s.io/klog/v2" v1 "k8s.io/kube-aggregator/pkg/apis/apiregistration/v1" scheme "k8s.io/kube-aggregator/pkg/client/clientset_generated/clientset/scheme" ) @@ -76,13 +78,22 @@ func (c *aPIServices) Get(ctx context.Context, name string, options metav1.GetOp } // List takes label and field selectors, and returns the list of APIServices that match those selectors. -func (c *aPIServices) List(ctx context.Context, opts metav1.ListOptions) (result *v1.APIServiceList, err error) { - defer func() { +func (c *aPIServices) List(ctx context.Context, opts metav1.ListOptions) (*v1.APIServiceList, error) { + if watchListOptions, hasWatchListOptionsPrepared, watchListOptionsErr := watchlist.PrepareWatchListOptionsFromListOptions(opts); watchListOptionsErr != nil { + klog.Warningf("Failed preparing watchlist options for apiservices, falling back to the standard LIST semantics, err = %v", watchListOptionsErr) + } else if hasWatchListOptionsPrepared { + result, err := c.watchList(ctx, watchListOptions) if err == nil { - consistencydetector.CheckListFromCacheDataConsistencyIfRequested(ctx, "list request for apiservices", c.list, opts, result) + consistencydetector.CheckWatchListFromCacheDataConsistencyIfRequested(ctx, "watchlist request for apiservices", c.list, opts, result) + return result, nil } - }() - return c.list(ctx, opts) + klog.Warningf("The watchlist request for apiservices ended with an error, falling back to the standard LIST semantics, err = %v", err) + } + result, err := c.list(ctx, opts) + if err == nil { + consistencydetector.CheckListFromCacheDataConsistencyIfRequested(ctx, "list request for apiservices", c.list, opts, result) + } + return result, err } // list takes label and field selectors, and returns the list of APIServices that match those selectors. @@ -101,6 +112,22 @@ func (c *aPIServices) list(ctx context.Context, opts metav1.ListOptions) (result return } +// watchList establishes a watch stream with the server and returns the list of APIServices +func (c *aPIServices) watchList(ctx context.Context, opts metav1.ListOptions) (result *v1.APIServiceList, err error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + result = &v1.APIServiceList{} + err = c.client.Get(). + Resource("apiservices"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + WatchList(ctx). + Into(result) + return +} + // Watch returns a watch.Interface that watches the requested aPIServices. func (c *aPIServices) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { var timeout time.Duration diff --git a/staging/src/k8s.io/kube-aggregator/pkg/client/clientset_generated/clientset/typed/apiregistration/v1beta1/apiservice.go b/staging/src/k8s.io/kube-aggregator/pkg/client/clientset_generated/clientset/typed/apiregistration/v1beta1/apiservice.go index 3097f3ab01f..0f53124fade 100644 --- a/staging/src/k8s.io/kube-aggregator/pkg/client/clientset_generated/clientset/typed/apiregistration/v1beta1/apiservice.go +++ b/staging/src/k8s.io/kube-aggregator/pkg/client/clientset_generated/clientset/typed/apiregistration/v1beta1/apiservice.go @@ -27,6 +27,8 @@ import ( watch "k8s.io/apimachinery/pkg/watch" rest "k8s.io/client-go/rest" consistencydetector "k8s.io/client-go/util/consistencydetector" + watchlist "k8s.io/client-go/util/watchlist" + "k8s.io/klog/v2" v1beta1 "k8s.io/kube-aggregator/pkg/apis/apiregistration/v1beta1" scheme "k8s.io/kube-aggregator/pkg/client/clientset_generated/clientset/scheme" ) @@ -76,13 +78,22 @@ func (c *aPIServices) Get(ctx context.Context, name string, options v1.GetOption } // List takes label and field selectors, and returns the list of APIServices that match those selectors. -func (c *aPIServices) List(ctx context.Context, opts v1.ListOptions) (result *v1beta1.APIServiceList, err error) { - defer func() { +func (c *aPIServices) List(ctx context.Context, opts v1.ListOptions) (*v1beta1.APIServiceList, error) { + if watchListOptions, hasWatchListOptionsPrepared, watchListOptionsErr := watchlist.PrepareWatchListOptionsFromListOptions(opts); watchListOptionsErr != nil { + klog.Warningf("Failed preparing watchlist options for apiservices, falling back to the standard LIST semantics, err = %v", watchListOptionsErr) + } else if hasWatchListOptionsPrepared { + result, err := c.watchList(ctx, watchListOptions) if err == nil { - consistencydetector.CheckListFromCacheDataConsistencyIfRequested(ctx, "list request for apiservices", c.list, opts, result) + consistencydetector.CheckWatchListFromCacheDataConsistencyIfRequested(ctx, "watchlist request for apiservices", c.list, opts, result) + return result, nil } - }() - return c.list(ctx, opts) + klog.Warningf("The watchlist request for apiservices ended with an error, falling back to the standard LIST semantics, err = %v", err) + } + result, err := c.list(ctx, opts) + if err == nil { + consistencydetector.CheckListFromCacheDataConsistencyIfRequested(ctx, "list request for apiservices", c.list, opts, result) + } + return result, err } // list takes label and field selectors, and returns the list of APIServices that match those selectors. @@ -101,6 +112,22 @@ func (c *aPIServices) list(ctx context.Context, opts v1.ListOptions) (result *v1 return } +// watchList establishes a watch stream with the server and returns the list of APIServices +func (c *aPIServices) watchList(ctx context.Context, opts v1.ListOptions) (result *v1beta1.APIServiceList, err error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + result = &v1beta1.APIServiceList{} + err = c.client.Get(). + Resource("apiservices"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + WatchList(ctx). + Into(result) + return +} + // Watch returns a watch.Interface that watches the requested aPIServices. func (c *aPIServices) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { var timeout time.Duration diff --git a/staging/src/k8s.io/metrics/pkg/client/clientset/versioned/typed/metrics/v1alpha1/nodemetrics.go b/staging/src/k8s.io/metrics/pkg/client/clientset/versioned/typed/metrics/v1alpha1/nodemetrics.go index 6b4ee30f772..6e20814047a 100644 --- a/staging/src/k8s.io/metrics/pkg/client/clientset/versioned/typed/metrics/v1alpha1/nodemetrics.go +++ b/staging/src/k8s.io/metrics/pkg/client/clientset/versioned/typed/metrics/v1alpha1/nodemetrics.go @@ -26,6 +26,8 @@ import ( watch "k8s.io/apimachinery/pkg/watch" rest "k8s.io/client-go/rest" consistencydetector "k8s.io/client-go/util/consistencydetector" + watchlist "k8s.io/client-go/util/watchlist" + "k8s.io/klog/v2" v1alpha1 "k8s.io/metrics/pkg/apis/metrics/v1alpha1" scheme "k8s.io/metrics/pkg/client/clientset/versioned/scheme" ) @@ -69,13 +71,22 @@ func (c *nodeMetricses) Get(ctx context.Context, name string, options v1.GetOpti } // List takes label and field selectors, and returns the list of NodeMetricses that match those selectors. -func (c *nodeMetricses) List(ctx context.Context, opts v1.ListOptions) (result *v1alpha1.NodeMetricsList, err error) { - defer func() { +func (c *nodeMetricses) List(ctx context.Context, opts v1.ListOptions) (*v1alpha1.NodeMetricsList, error) { + if watchListOptions, hasWatchListOptionsPrepared, watchListOptionsErr := watchlist.PrepareWatchListOptionsFromListOptions(opts); watchListOptionsErr != nil { + klog.Warningf("Failed preparing watchlist options for nodes, falling back to the standard LIST semantics, err = %v", watchListOptionsErr) + } else if hasWatchListOptionsPrepared { + result, err := c.watchList(ctx, watchListOptions) if err == nil { - consistencydetector.CheckListFromCacheDataConsistencyIfRequested(ctx, "list request for nodes", c.list, opts, result) + consistencydetector.CheckWatchListFromCacheDataConsistencyIfRequested(ctx, "watchlist request for nodes", c.list, opts, result) + return result, nil } - }() - return c.list(ctx, opts) + klog.Warningf("The watchlist request for nodes ended with an error, falling back to the standard LIST semantics, err = %v", err) + } + result, err := c.list(ctx, opts) + if err == nil { + consistencydetector.CheckListFromCacheDataConsistencyIfRequested(ctx, "list request for nodes", c.list, opts, result) + } + return result, err } // list takes label and field selectors, and returns the list of NodeMetricses that match those selectors. @@ -94,6 +105,22 @@ func (c *nodeMetricses) list(ctx context.Context, opts v1.ListOptions) (result * return } +// watchList establishes a watch stream with the server and returns the list of NodeMetricses +func (c *nodeMetricses) watchList(ctx context.Context, opts v1.ListOptions) (result *v1alpha1.NodeMetricsList, err error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + result = &v1alpha1.NodeMetricsList{} + err = c.client.Get(). + Resource("nodes"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + WatchList(ctx). + Into(result) + return +} + // Watch returns a watch.Interface that watches the requested nodeMetricses. func (c *nodeMetricses) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { var timeout time.Duration diff --git a/staging/src/k8s.io/metrics/pkg/client/clientset/versioned/typed/metrics/v1alpha1/podmetrics.go b/staging/src/k8s.io/metrics/pkg/client/clientset/versioned/typed/metrics/v1alpha1/podmetrics.go index 25d77344cfb..92515cc039a 100644 --- a/staging/src/k8s.io/metrics/pkg/client/clientset/versioned/typed/metrics/v1alpha1/podmetrics.go +++ b/staging/src/k8s.io/metrics/pkg/client/clientset/versioned/typed/metrics/v1alpha1/podmetrics.go @@ -26,6 +26,8 @@ import ( watch "k8s.io/apimachinery/pkg/watch" rest "k8s.io/client-go/rest" consistencydetector "k8s.io/client-go/util/consistencydetector" + watchlist "k8s.io/client-go/util/watchlist" + "k8s.io/klog/v2" v1alpha1 "k8s.io/metrics/pkg/apis/metrics/v1alpha1" scheme "k8s.io/metrics/pkg/client/clientset/versioned/scheme" ) @@ -72,13 +74,22 @@ func (c *podMetricses) Get(ctx context.Context, name string, options v1.GetOptio } // List takes label and field selectors, and returns the list of PodMetricses that match those selectors. -func (c *podMetricses) List(ctx context.Context, opts v1.ListOptions) (result *v1alpha1.PodMetricsList, err error) { - defer func() { +func (c *podMetricses) List(ctx context.Context, opts v1.ListOptions) (*v1alpha1.PodMetricsList, error) { + if watchListOptions, hasWatchListOptionsPrepared, watchListOptionsErr := watchlist.PrepareWatchListOptionsFromListOptions(opts); watchListOptionsErr != nil { + klog.Warningf("Failed preparing watchlist options for pods, falling back to the standard LIST semantics, err = %v", watchListOptionsErr) + } else if hasWatchListOptionsPrepared { + result, err := c.watchList(ctx, watchListOptions) if err == nil { - consistencydetector.CheckListFromCacheDataConsistencyIfRequested(ctx, "list request for pods", c.list, opts, result) + consistencydetector.CheckWatchListFromCacheDataConsistencyIfRequested(ctx, "watchlist request for pods", c.list, opts, result) + return result, nil } - }() - return c.list(ctx, opts) + klog.Warningf("The watchlist request for pods ended with an error, falling back to the standard LIST semantics, err = %v", err) + } + result, err := c.list(ctx, opts) + if err == nil { + consistencydetector.CheckListFromCacheDataConsistencyIfRequested(ctx, "list request for pods", c.list, opts, result) + } + return result, err } // list takes label and field selectors, and returns the list of PodMetricses that match those selectors. @@ -98,6 +109,23 @@ func (c *podMetricses) list(ctx context.Context, opts v1.ListOptions) (result *v return } +// watchList establishes a watch stream with the server and returns the list of PodMetricses +func (c *podMetricses) watchList(ctx context.Context, opts v1.ListOptions) (result *v1alpha1.PodMetricsList, err error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + result = &v1alpha1.PodMetricsList{} + err = c.client.Get(). + Namespace(c.ns). + Resource("pods"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + WatchList(ctx). + Into(result) + return +} + // Watch returns a watch.Interface that watches the requested podMetricses. func (c *podMetricses) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { var timeout time.Duration diff --git a/staging/src/k8s.io/metrics/pkg/client/clientset/versioned/typed/metrics/v1beta1/nodemetrics.go b/staging/src/k8s.io/metrics/pkg/client/clientset/versioned/typed/metrics/v1beta1/nodemetrics.go index 900428e3169..02564f0ec13 100644 --- a/staging/src/k8s.io/metrics/pkg/client/clientset/versioned/typed/metrics/v1beta1/nodemetrics.go +++ b/staging/src/k8s.io/metrics/pkg/client/clientset/versioned/typed/metrics/v1beta1/nodemetrics.go @@ -26,6 +26,8 @@ import ( watch "k8s.io/apimachinery/pkg/watch" rest "k8s.io/client-go/rest" consistencydetector "k8s.io/client-go/util/consistencydetector" + watchlist "k8s.io/client-go/util/watchlist" + "k8s.io/klog/v2" v1beta1 "k8s.io/metrics/pkg/apis/metrics/v1beta1" scheme "k8s.io/metrics/pkg/client/clientset/versioned/scheme" ) @@ -69,13 +71,22 @@ func (c *nodeMetricses) Get(ctx context.Context, name string, options v1.GetOpti } // List takes label and field selectors, and returns the list of NodeMetricses that match those selectors. -func (c *nodeMetricses) List(ctx context.Context, opts v1.ListOptions) (result *v1beta1.NodeMetricsList, err error) { - defer func() { +func (c *nodeMetricses) List(ctx context.Context, opts v1.ListOptions) (*v1beta1.NodeMetricsList, error) { + if watchListOptions, hasWatchListOptionsPrepared, watchListOptionsErr := watchlist.PrepareWatchListOptionsFromListOptions(opts); watchListOptionsErr != nil { + klog.Warningf("Failed preparing watchlist options for nodes, falling back to the standard LIST semantics, err = %v", watchListOptionsErr) + } else if hasWatchListOptionsPrepared { + result, err := c.watchList(ctx, watchListOptions) if err == nil { - consistencydetector.CheckListFromCacheDataConsistencyIfRequested(ctx, "list request for nodes", c.list, opts, result) + consistencydetector.CheckWatchListFromCacheDataConsistencyIfRequested(ctx, "watchlist request for nodes", c.list, opts, result) + return result, nil } - }() - return c.list(ctx, opts) + klog.Warningf("The watchlist request for nodes ended with an error, falling back to the standard LIST semantics, err = %v", err) + } + result, err := c.list(ctx, opts) + if err == nil { + consistencydetector.CheckListFromCacheDataConsistencyIfRequested(ctx, "list request for nodes", c.list, opts, result) + } + return result, err } // list takes label and field selectors, and returns the list of NodeMetricses that match those selectors. @@ -94,6 +105,22 @@ func (c *nodeMetricses) list(ctx context.Context, opts v1.ListOptions) (result * return } +// watchList establishes a watch stream with the server and returns the list of NodeMetricses +func (c *nodeMetricses) watchList(ctx context.Context, opts v1.ListOptions) (result *v1beta1.NodeMetricsList, err error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + result = &v1beta1.NodeMetricsList{} + err = c.client.Get(). + Resource("nodes"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + WatchList(ctx). + Into(result) + return +} + // Watch returns a watch.Interface that watches the requested nodeMetricses. func (c *nodeMetricses) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { var timeout time.Duration diff --git a/staging/src/k8s.io/metrics/pkg/client/clientset/versioned/typed/metrics/v1beta1/podmetrics.go b/staging/src/k8s.io/metrics/pkg/client/clientset/versioned/typed/metrics/v1beta1/podmetrics.go index 7f43574ac92..06b76a2928c 100644 --- a/staging/src/k8s.io/metrics/pkg/client/clientset/versioned/typed/metrics/v1beta1/podmetrics.go +++ b/staging/src/k8s.io/metrics/pkg/client/clientset/versioned/typed/metrics/v1beta1/podmetrics.go @@ -26,6 +26,8 @@ import ( watch "k8s.io/apimachinery/pkg/watch" rest "k8s.io/client-go/rest" consistencydetector "k8s.io/client-go/util/consistencydetector" + watchlist "k8s.io/client-go/util/watchlist" + "k8s.io/klog/v2" v1beta1 "k8s.io/metrics/pkg/apis/metrics/v1beta1" scheme "k8s.io/metrics/pkg/client/clientset/versioned/scheme" ) @@ -72,13 +74,22 @@ func (c *podMetricses) Get(ctx context.Context, name string, options v1.GetOptio } // List takes label and field selectors, and returns the list of PodMetricses that match those selectors. -func (c *podMetricses) List(ctx context.Context, opts v1.ListOptions) (result *v1beta1.PodMetricsList, err error) { - defer func() { +func (c *podMetricses) List(ctx context.Context, opts v1.ListOptions) (*v1beta1.PodMetricsList, error) { + if watchListOptions, hasWatchListOptionsPrepared, watchListOptionsErr := watchlist.PrepareWatchListOptionsFromListOptions(opts); watchListOptionsErr != nil { + klog.Warningf("Failed preparing watchlist options for pods, falling back to the standard LIST semantics, err = %v", watchListOptionsErr) + } else if hasWatchListOptionsPrepared { + result, err := c.watchList(ctx, watchListOptions) if err == nil { - consistencydetector.CheckListFromCacheDataConsistencyIfRequested(ctx, "list request for pods", c.list, opts, result) + consistencydetector.CheckWatchListFromCacheDataConsistencyIfRequested(ctx, "watchlist request for pods", c.list, opts, result) + return result, nil } - }() - return c.list(ctx, opts) + klog.Warningf("The watchlist request for pods ended with an error, falling back to the standard LIST semantics, err = %v", err) + } + result, err := c.list(ctx, opts) + if err == nil { + consistencydetector.CheckListFromCacheDataConsistencyIfRequested(ctx, "list request for pods", c.list, opts, result) + } + return result, err } // list takes label and field selectors, and returns the list of PodMetricses that match those selectors. @@ -98,6 +109,23 @@ func (c *podMetricses) list(ctx context.Context, opts v1.ListOptions) (result *v return } +// watchList establishes a watch stream with the server and returns the list of PodMetricses +func (c *podMetricses) watchList(ctx context.Context, opts v1.ListOptions) (result *v1beta1.PodMetricsList, err error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + result = &v1beta1.PodMetricsList{} + err = c.client.Get(). + Namespace(c.ns). + Resource("pods"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + WatchList(ctx). + Into(result) + return +} + // Watch returns a watch.Interface that watches the requested podMetricses. func (c *podMetricses) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { var timeout time.Duration diff --git a/staging/src/k8s.io/sample-apiserver/pkg/generated/clientset/versioned/typed/wardle/v1alpha1/fischer.go b/staging/src/k8s.io/sample-apiserver/pkg/generated/clientset/versioned/typed/wardle/v1alpha1/fischer.go index d6e8ec56ac6..4c42c242666 100644 --- a/staging/src/k8s.io/sample-apiserver/pkg/generated/clientset/versioned/typed/wardle/v1alpha1/fischer.go +++ b/staging/src/k8s.io/sample-apiserver/pkg/generated/clientset/versioned/typed/wardle/v1alpha1/fischer.go @@ -29,6 +29,8 @@ import ( watch "k8s.io/apimachinery/pkg/watch" rest "k8s.io/client-go/rest" consistencydetector "k8s.io/client-go/util/consistencydetector" + watchlist "k8s.io/client-go/util/watchlist" + "k8s.io/klog/v2" v1alpha1 "k8s.io/sample-apiserver/pkg/apis/wardle/v1alpha1" wardlev1alpha1 "k8s.io/sample-apiserver/pkg/generated/applyconfiguration/wardle/v1alpha1" scheme "k8s.io/sample-apiserver/pkg/generated/clientset/versioned/scheme" @@ -79,13 +81,22 @@ func (c *fischers) Get(ctx context.Context, name string, options v1.GetOptions) } // List takes label and field selectors, and returns the list of Fischers that match those selectors. -func (c *fischers) List(ctx context.Context, opts v1.ListOptions) (result *v1alpha1.FischerList, err error) { - defer func() { +func (c *fischers) List(ctx context.Context, opts v1.ListOptions) (*v1alpha1.FischerList, error) { + if watchListOptions, hasWatchListOptionsPrepared, watchListOptionsErr := watchlist.PrepareWatchListOptionsFromListOptions(opts); watchListOptionsErr != nil { + klog.Warningf("Failed preparing watchlist options for fischers, falling back to the standard LIST semantics, err = %v", watchListOptionsErr) + } else if hasWatchListOptionsPrepared { + result, err := c.watchList(ctx, watchListOptions) if err == nil { - consistencydetector.CheckListFromCacheDataConsistencyIfRequested(ctx, "list request for fischers", c.list, opts, result) + consistencydetector.CheckWatchListFromCacheDataConsistencyIfRequested(ctx, "watchlist request for fischers", c.list, opts, result) + return result, nil } - }() - return c.list(ctx, opts) + klog.Warningf("The watchlist request for fischers ended with an error, falling back to the standard LIST semantics, err = %v", err) + } + result, err := c.list(ctx, opts) + if err == nil { + consistencydetector.CheckListFromCacheDataConsistencyIfRequested(ctx, "list request for fischers", c.list, opts, result) + } + return result, err } // list takes label and field selectors, and returns the list of Fischers that match those selectors. @@ -104,6 +115,22 @@ func (c *fischers) list(ctx context.Context, opts v1.ListOptions) (result *v1alp return } +// watchList establishes a watch stream with the server and returns the list of Fischers +func (c *fischers) watchList(ctx context.Context, opts v1.ListOptions) (result *v1alpha1.FischerList, err error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + result = &v1alpha1.FischerList{} + err = c.client.Get(). + Resource("fischers"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + WatchList(ctx). + Into(result) + return +} + // Watch returns a watch.Interface that watches the requested fischers. func (c *fischers) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { var timeout time.Duration diff --git a/staging/src/k8s.io/sample-apiserver/pkg/generated/clientset/versioned/typed/wardle/v1alpha1/flunder.go b/staging/src/k8s.io/sample-apiserver/pkg/generated/clientset/versioned/typed/wardle/v1alpha1/flunder.go index 3c80e07c1df..530e587dc39 100644 --- a/staging/src/k8s.io/sample-apiserver/pkg/generated/clientset/versioned/typed/wardle/v1alpha1/flunder.go +++ b/staging/src/k8s.io/sample-apiserver/pkg/generated/clientset/versioned/typed/wardle/v1alpha1/flunder.go @@ -29,6 +29,8 @@ import ( watch "k8s.io/apimachinery/pkg/watch" rest "k8s.io/client-go/rest" consistencydetector "k8s.io/client-go/util/consistencydetector" + watchlist "k8s.io/client-go/util/watchlist" + "k8s.io/klog/v2" v1alpha1 "k8s.io/sample-apiserver/pkg/apis/wardle/v1alpha1" wardlev1alpha1 "k8s.io/sample-apiserver/pkg/generated/applyconfiguration/wardle/v1alpha1" scheme "k8s.io/sample-apiserver/pkg/generated/clientset/versioned/scheme" @@ -84,13 +86,22 @@ func (c *flunders) Get(ctx context.Context, name string, options v1.GetOptions) } // List takes label and field selectors, and returns the list of Flunders that match those selectors. -func (c *flunders) List(ctx context.Context, opts v1.ListOptions) (result *v1alpha1.FlunderList, err error) { - defer func() { +func (c *flunders) List(ctx context.Context, opts v1.ListOptions) (*v1alpha1.FlunderList, error) { + if watchListOptions, hasWatchListOptionsPrepared, watchListOptionsErr := watchlist.PrepareWatchListOptionsFromListOptions(opts); watchListOptionsErr != nil { + klog.Warningf("Failed preparing watchlist options for flunders, falling back to the standard LIST semantics, err = %v", watchListOptionsErr) + } else if hasWatchListOptionsPrepared { + result, err := c.watchList(ctx, watchListOptions) if err == nil { - consistencydetector.CheckListFromCacheDataConsistencyIfRequested(ctx, "list request for flunders", c.list, opts, result) + consistencydetector.CheckWatchListFromCacheDataConsistencyIfRequested(ctx, "watchlist request for flunders", c.list, opts, result) + return result, nil } - }() - return c.list(ctx, opts) + klog.Warningf("The watchlist request for flunders ended with an error, falling back to the standard LIST semantics, err = %v", err) + } + result, err := c.list(ctx, opts) + if err == nil { + consistencydetector.CheckListFromCacheDataConsistencyIfRequested(ctx, "list request for flunders", c.list, opts, result) + } + return result, err } // list takes label and field selectors, and returns the list of Flunders that match those selectors. @@ -110,6 +121,23 @@ func (c *flunders) list(ctx context.Context, opts v1.ListOptions) (result *v1alp return } +// watchList establishes a watch stream with the server and returns the list of Flunders +func (c *flunders) watchList(ctx context.Context, opts v1.ListOptions) (result *v1alpha1.FlunderList, err error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + result = &v1alpha1.FlunderList{} + err = c.client.Get(). + Namespace(c.ns). + Resource("flunders"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + WatchList(ctx). + Into(result) + return +} + // Watch returns a watch.Interface that watches the requested flunders. func (c *flunders) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { var timeout time.Duration diff --git a/staging/src/k8s.io/sample-apiserver/pkg/generated/clientset/versioned/typed/wardle/v1beta1/flunder.go b/staging/src/k8s.io/sample-apiserver/pkg/generated/clientset/versioned/typed/wardle/v1beta1/flunder.go index 88bfddf13a1..3f607dcc820 100644 --- a/staging/src/k8s.io/sample-apiserver/pkg/generated/clientset/versioned/typed/wardle/v1beta1/flunder.go +++ b/staging/src/k8s.io/sample-apiserver/pkg/generated/clientset/versioned/typed/wardle/v1beta1/flunder.go @@ -29,6 +29,8 @@ import ( watch "k8s.io/apimachinery/pkg/watch" rest "k8s.io/client-go/rest" consistencydetector "k8s.io/client-go/util/consistencydetector" + watchlist "k8s.io/client-go/util/watchlist" + "k8s.io/klog/v2" v1beta1 "k8s.io/sample-apiserver/pkg/apis/wardle/v1beta1" wardlev1beta1 "k8s.io/sample-apiserver/pkg/generated/applyconfiguration/wardle/v1beta1" scheme "k8s.io/sample-apiserver/pkg/generated/clientset/versioned/scheme" @@ -84,13 +86,22 @@ func (c *flunders) Get(ctx context.Context, name string, options v1.GetOptions) } // List takes label and field selectors, and returns the list of Flunders that match those selectors. -func (c *flunders) List(ctx context.Context, opts v1.ListOptions) (result *v1beta1.FlunderList, err error) { - defer func() { +func (c *flunders) List(ctx context.Context, opts v1.ListOptions) (*v1beta1.FlunderList, error) { + if watchListOptions, hasWatchListOptionsPrepared, watchListOptionsErr := watchlist.PrepareWatchListOptionsFromListOptions(opts); watchListOptionsErr != nil { + klog.Warningf("Failed preparing watchlist options for flunders, falling back to the standard LIST semantics, err = %v", watchListOptionsErr) + } else if hasWatchListOptionsPrepared { + result, err := c.watchList(ctx, watchListOptions) if err == nil { - consistencydetector.CheckListFromCacheDataConsistencyIfRequested(ctx, "list request for flunders", c.list, opts, result) + consistencydetector.CheckWatchListFromCacheDataConsistencyIfRequested(ctx, "watchlist request for flunders", c.list, opts, result) + return result, nil } - }() - return c.list(ctx, opts) + klog.Warningf("The watchlist request for flunders ended with an error, falling back to the standard LIST semantics, err = %v", err) + } + result, err := c.list(ctx, opts) + if err == nil { + consistencydetector.CheckListFromCacheDataConsistencyIfRequested(ctx, "list request for flunders", c.list, opts, result) + } + return result, err } // list takes label and field selectors, and returns the list of Flunders that match those selectors. @@ -110,6 +121,23 @@ func (c *flunders) list(ctx context.Context, opts v1.ListOptions) (result *v1bet return } +// watchList establishes a watch stream with the server and returns the list of Flunders +func (c *flunders) watchList(ctx context.Context, opts v1.ListOptions) (result *v1beta1.FlunderList, err error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + result = &v1beta1.FlunderList{} + err = c.client.Get(). + Namespace(c.ns). + Resource("flunders"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + WatchList(ctx). + Into(result) + return +} + // Watch returns a watch.Interface that watches the requested flunders. func (c *flunders) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { var timeout time.Duration diff --git a/staging/src/k8s.io/sample-controller/pkg/generated/clientset/versioned/typed/samplecontroller/v1alpha1/foo.go b/staging/src/k8s.io/sample-controller/pkg/generated/clientset/versioned/typed/samplecontroller/v1alpha1/foo.go index d09fd325a44..13a0b46de5d 100644 --- a/staging/src/k8s.io/sample-controller/pkg/generated/clientset/versioned/typed/samplecontroller/v1alpha1/foo.go +++ b/staging/src/k8s.io/sample-controller/pkg/generated/clientset/versioned/typed/samplecontroller/v1alpha1/foo.go @@ -27,6 +27,8 @@ import ( watch "k8s.io/apimachinery/pkg/watch" rest "k8s.io/client-go/rest" consistencydetector "k8s.io/client-go/util/consistencydetector" + watchlist "k8s.io/client-go/util/watchlist" + "k8s.io/klog/v2" v1alpha1 "k8s.io/sample-controller/pkg/apis/samplecontroller/v1alpha1" scheme "k8s.io/sample-controller/pkg/generated/clientset/versioned/scheme" ) @@ -79,13 +81,22 @@ func (c *foos) Get(ctx context.Context, name string, options v1.GetOptions) (res } // List takes label and field selectors, and returns the list of Foos that match those selectors. -func (c *foos) List(ctx context.Context, opts v1.ListOptions) (result *v1alpha1.FooList, err error) { - defer func() { +func (c *foos) List(ctx context.Context, opts v1.ListOptions) (*v1alpha1.FooList, error) { + if watchListOptions, hasWatchListOptionsPrepared, watchListOptionsErr := watchlist.PrepareWatchListOptionsFromListOptions(opts); watchListOptionsErr != nil { + klog.Warningf("Failed preparing watchlist options for foos, falling back to the standard LIST semantics, err = %v", watchListOptionsErr) + } else if hasWatchListOptionsPrepared { + result, err := c.watchList(ctx, watchListOptions) if err == nil { - consistencydetector.CheckListFromCacheDataConsistencyIfRequested(ctx, "list request for foos", c.list, opts, result) + consistencydetector.CheckWatchListFromCacheDataConsistencyIfRequested(ctx, "watchlist request for foos", c.list, opts, result) + return result, nil } - }() - return c.list(ctx, opts) + klog.Warningf("The watchlist request for foos ended with an error, falling back to the standard LIST semantics, err = %v", err) + } + result, err := c.list(ctx, opts) + if err == nil { + consistencydetector.CheckListFromCacheDataConsistencyIfRequested(ctx, "list request for foos", c.list, opts, result) + } + return result, err } // list takes label and field selectors, and returns the list of Foos that match those selectors. @@ -105,6 +116,23 @@ func (c *foos) list(ctx context.Context, opts v1.ListOptions) (result *v1alpha1. return } +// watchList establishes a watch stream with the server and returns the list of Foos +func (c *foos) watchList(ctx context.Context, opts v1.ListOptions) (result *v1alpha1.FooList, err error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + result = &v1alpha1.FooList{} + err = c.client.Get(). + Namespace(c.ns). + Resource("foos"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + WatchList(ctx). + Into(result) + return +} + // Watch returns a watch.Interface that watches the requested foos. func (c *foos) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { var timeout time.Duration From 9871fcab393fb970906ea09d460b278e1f1e720b Mon Sep 17 00:00:00 2001 From: Lukasz Szaszkiewicz Date: Thu, 13 Jun 2024 17:24:12 +0200 Subject: [PATCH 4/4] ./hack/update-internal-modules.sh --- staging/src/k8s.io/code-generator/examples/go.mod | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/staging/src/k8s.io/code-generator/examples/go.mod b/staging/src/k8s.io/code-generator/examples/go.mod index 7f255b4513e..362a3e22177 100644 --- a/staging/src/k8s.io/code-generator/examples/go.mod +++ b/staging/src/k8s.io/code-generator/examples/go.mod @@ -8,6 +8,7 @@ require ( k8s.io/api v0.0.0 k8s.io/apimachinery v0.0.0 k8s.io/client-go v0.0.0 + k8s.io/klog/v2 v2.120.1 k8s.io/kube-openapi v0.0.0-20240228011516-70dd3763d340 sigs.k8s.io/structured-merge-diff/v4 v4.4.1 ) @@ -45,7 +46,6 @@ require ( gopkg.in/inf.v0 v0.9.1 // indirect gopkg.in/yaml.v2 v2.4.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect - k8s.io/klog/v2 v2.120.1 // indirect k8s.io/utils v0.0.0-20230726121419-3b25d923346b // indirect sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect sigs.k8s.io/yaml v1.4.0 // indirect