From 5d84e91dbf4b609b429d5c978d1b6ae0649f9d5a Mon Sep 17 00:00:00 2001 From: Lukasz Szaszkiewicz Date: Tue, 4 Jun 2024 10:23:19 +0200 Subject: [PATCH] client-go/dynamic: use CheckListFromCacheDataConsistencyIfRequested Kubernetes-commit: 79370c6d676814758c60bbc1b71a882583be2214 --- dynamic/simple.go | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/dynamic/simple.go b/dynamic/simple.go index 4b548595..9ea8ef36 100644 --- a/dynamic/simple.go +++ b/dynamic/simple.go @@ -29,6 +29,7 @@ import ( "k8s.io/apimachinery/pkg/types" "k8s.io/apimachinery/pkg/watch" "k8s.io/client-go/rest" + "k8s.io/client-go/util/consistencydetector" ) type DynamicClient struct { @@ -292,7 +293,16 @@ func (c *dynamicResourceClient) Get(ctx context.Context, name string, opts metav return uncastObj.(*unstructured.Unstructured), nil } -func (c *dynamicResourceClient) List(ctx context.Context, opts metav1.ListOptions) (*unstructured.UnstructuredList, error) { +func (c *dynamicResourceClient) List(ctx context.Context, opts metav1.ListOptions) (result *unstructured.UnstructuredList, err error) { + defer func() { + if err == nil { + consistencydetector.CheckListFromCacheDataConsistencyIfRequested(ctx, fmt.Sprintf("list request for %v", c.resource), c.list, opts, result) + } + }() + return c.list(ctx, opts) +} + +func (c *dynamicResourceClient) list(ctx context.Context, opts metav1.ListOptions) (*unstructured.UnstructuredList, error) { if err := validateNamespaceWithOptionalName(c.namespace); err != nil { return nil, err }