Skip to content

is there a way to make client.Get to not get from cache #585

@chenzhiwei

Description

@chenzhiwei

Hi, I have a case that I need to use client.Get() immediately after running client.Status().Update().

The client.Get() will get the object from cache, this is not what I want.

The implementation:

// Get retrieves an obj for a given object key from the Kubernetes Cluster.
func (d *DelegatingReader) Get(ctx context.Context, key ObjectKey, obj runtime.Object) error {
_, isUnstructured := obj.(*unstructured.Unstructured)
if isUnstructured {
return d.ClientReader.Get(ctx, key, obj)
}
return d.CacheReader.Get(ctx, key, obj)
}

I don't want to use CacheReader and I also can't use unstructured Object.

Is there a way to make sure client.Get() to get the realtime result? Maybe wait for cache to sync? I don't know how.

My code is something like: https://github.com/operator-framework/operator-sdk/blob/d6903be02d4e8541e777b25af0498fe31e2e41e8/internal/pkg/scaffold/controller_kind.go#L213-L219

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions