GoogleCloudPlatform / k8s-config-connector

GCP Config Connector, a Kubernetes add-on for managing GCP resources
https://cloud.google.com/config-connector/docs/overview
Apache License 2.0
884 stars 217 forks source link

Verify that caching behaviour is correct #1362

Open justinsb opened 6 months ago

justinsb commented 6 months ago

Checklist

Describe the feature or resource

controller-runtime's caching configuration is fairly complicated, and I'm not sure we have it right. We need a test or at least manual verification that we are not caching most objects, but are caching the CC/CCC.

Additional information

No response

Importance

No response

justinsb commented 6 months ago

I verified the behaviour. It looks like there is always an informer cache for the subject of any controller, but that we use ObjectMeta to reduce the footprint (we pass builder.OnlyMetadata).

We are now watching CC and CCC objects (along with CRDs).

I think we can build a test for this by watching the kube-apiserver calls and looking for watch requests (?watch=true) that return a content-type of application/json vs application/json;as=PartialObjectMetadataList;g=meta.k8s.io;v=v1.

However, it's a little thorny and the behaviour appears correct (the "big trick" is that unstructured objects are never cached by default), so I think we can move to 1.115