Skip to content

Commit e328c8f

Browse files
authored
Merge pull request kubernetes#125304 from p0lyn0mial/upstream-dynamic-client-uses-consistency-detector
dynamic-client: data consistency checker for list requests
2 parents 6b73ccc + 79370c6 commit e328c8f

File tree

1 file changed

+11
-1
lines changed
  • staging/src/k8s.io/client-go/dynamic

1 file changed

+11
-1
lines changed

staging/src/k8s.io/client-go/dynamic/simple.go

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ import (
2929
"k8s.io/apimachinery/pkg/types"
3030
"k8s.io/apimachinery/pkg/watch"
3131
"k8s.io/client-go/rest"
32+
"k8s.io/client-go/util/consistencydetector"
3233
)
3334

3435
type DynamicClient struct {
@@ -292,7 +293,16 @@ func (c *dynamicResourceClient) Get(ctx context.Context, name string, opts metav
292293
return uncastObj.(*unstructured.Unstructured), nil
293294
}
294295

295-
func (c *dynamicResourceClient) List(ctx context.Context, opts metav1.ListOptions) (*unstructured.UnstructuredList, error) {
296+
func (c *dynamicResourceClient) List(ctx context.Context, opts metav1.ListOptions) (result *unstructured.UnstructuredList, err error) {
297+
defer func() {
298+
if err == nil {
299+
consistencydetector.CheckListFromCacheDataConsistencyIfRequested(ctx, fmt.Sprintf("list request for %v", c.resource), c.list, opts, result)
300+
}
301+
}()
302+
return c.list(ctx, opts)
303+
}
304+
305+
func (c *dynamicResourceClient) list(ctx context.Context, opts metav1.ListOptions) (*unstructured.UnstructuredList, error) {
296306
if err := validateNamespaceWithOptionalName(c.namespace); err != nil {
297307
return nil, err
298308
}

0 commit comments

Comments
 (0)