mirror of
https://github.com/kubernetes/client-go.git
synced 2025-06-24 06:07:48 +00:00
Merge pull request #125304 from p0lyn0mial/upstream-dynamic-client-uses-consistency-detector
dynamic-client: data consistency checker for list requests Kubernetes-commit: e328c8fbf18f50e3d9dff430af482e703124147d
This commit is contained in:
commit
c415c7650f
@ -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
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user