argoproj / gitops-engine

Democratizing GitOps
https://pkg.go.dev/github.com/argoproj/gitops-engine?tab=subdirectories
Apache License 2.0
1.7k stars 260 forks source link

Resource API discovery results do not appear to come from a cache #451

Open jessesuen opened 2 years ago

jessesuen commented 2 years ago

It was discovered in https://github.com/argoproj/gitops-engine/pull/449#issuecomment-1220738665 that controller was making 1M api calls to perform discovery.

The client-go does seem to provide a cached discovery option, but based on evidence of API calls, we may not be taking advantage of it

https://pkg.go.dev/k8s.io/client-go/discovery#CachedDiscoveryInterface

crenshaw-dev commented 2 years ago

This is a partial fix: https://github.com/argoproj/gitops-engine/pull/448/files

KubectlCmd calls that require GVK info instantiate and use a one-off discovery client. Fixing that will require a bigger refactor, so I left it for later.

crenshaw-dev commented 2 years ago

^ that fix pays no attention to the cluster changes which should invalidate the cache, so we probably shouldn't merge it as-is.