Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Call to get namespaced resources is calling the API to retrieve them all? #3122

Open
ggallen opened this issue Feb 18, 2025 · 8 comments
Open

Comments

@ggallen
Copy link

ggallen commented Feb 18, 2025

I seem to see this this call:

	cm := &corev1.ConfigMap{}
	err := r.Get(ctx, types.NamespacedName{Name: "sink-filters", Namespace: "kubearchive"}, cm)

Translating into this request under the covers:

https://10.96.0.1:443/api/v1/configmaps?limit=500&resourceVersion=0

Even though I have specified a name and a namespace, it seems to be trying to get all (up to 500) ConfigMaps. Is this expected behavior or is my call somehow wrong?

@troy0820
Copy link
Member

Interesting. That's a different endpoint used for list. Are you listing the configmaps anywhere?

This is the endpoing for GET:
GET /api/v1/namespaces/{namespace}/configmaps/{name}

What version of CR are you running?

@ggallen
Copy link
Author

ggallen commented Feb 18, 2025

@troy0820, you can see the call here.

I don't believe I call list anywhere in my operator.

Note that I am using OTEL to find the call. The only GET to ConfigMaps that I see in my output is the one I listed.

@ggallen
Copy link
Author

ggallen commented Feb 18, 2025

My controller-runtime version:

[gallen@gallen-thinkpadp1gen5 kubearchive] (issue-780)$ grep controller-runtime go.mod
	sigs.k8s.io/controller-runtime v0.20.2
[gallen@gallen-thinkpadp1gen5 kubearchive] (issue-780)$ 

@ggallen
Copy link
Author

ggallen commented Feb 18, 2025

Note also that I see the same behavior for all GET requests. It's not just this resource.

@bigkevmcd
Copy link
Contributor

@ggallen do you see any queries that include /api/v1/configmaps and watch=true you are watching ConfigMaps if it's early on in the code, is this the caching being populated for the watch?

@ggallen
Copy link
Author

ggallen commented Feb 18, 2025

@bigkevmcd, I'll take a look. Are you saying that I am watching ConfigMaps? Because I don't think that I did that intentionally.

@ggallen
Copy link
Author

ggallen commented Feb 18, 2025

I don't believe there are any watches.

@sbueringer
Copy link
Member

If you use the client from mgr.GetClient() you are using the cached client which per default internally creates an informer (including list+watch) after the first get or list call

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants