-
Notifications
You must be signed in to change notification settings - Fork 48
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
✨ Restrict cache for all ConfigMap/Secret objects #722
base: main
Are you sure you want to change the base?
Conversation
This patch updates the manager cache for VM Operator so that ConfigMap/Secret resources from the kube-system and VM Op pod namespaces are cached, but ConfigMap/Secret resources in any other namespace are *not* cached. This patch means controllers that access ConfigMap/Secret resources in these namespaces no longer need to create separate caches. Instead, all controllers may use the manager client unless for some other reason.
@sbueringer Ugh. This is failing with: $ go test -timeout 120s -run '^TestManager$' ./pkg/manager/test
Running Suite: Manager Suite - /Users/akutz/Projects/vmop/vmop/pkg/manager/test
===============================================================================
Random Seed: 1727195109
Will run 3 of 3 specs
------------------------------
• [FAILED] [0.022 seconds]
Integration tests Cache Getting objects ConfigMap [It] should return the object with a live read [envtest]
/Users/akutz/Projects/vmop/vmop/pkg/manager/test/cache_test.go:57
Timeline >>
STEP: Creating a temporary namespace @ 09/24/24 11:25:15.684
[FAILED] in [It] - /Users/akutz/Projects/vmop/vmop/pkg/manager/test/cache_test.go:58 @ 09/24/24 11:25:15.702
STEP: Destroying temporary namespace @ 09/24/24 11:25:15.702
<< Timeline
[FAILED] Expected success, but got an error:
<*errors.errorString | 0x14000e06050>:
unable to get: 2c57ba0a-9e3c-44eb-8721-b68a1bf4f65c/my-object-7kbwc because of unknown namespace for the cache
{
s: "unable to get: 2c57ba0a-9e3c-44eb-8721-b68a1bf4f65c/my-object-7kbwc because of unknown namespace for the cache",
}
In [It] at: /Users/akutz/Projects/vmop/vmop/pkg/manager/test/cache_test.go:58 @ 09/24/24 11:25:15.702
------------------------------
SSI0924 11:25:15.707798 99028 internal.go:538] "Stopping and waiting for non leader election runnables"
I0924 11:25:15.707837 99028 internal.go:542] "Stopping and waiting for leader election runnables"
I0924 11:25:15.707857 99028 internal.go:550] "Stopping and waiting for caches"
I0924 11:25:15.707954 99028 internal.go:554] "Stopping and waiting for webhooks"
I0924 11:25:15.707967 99028 internal.go:557] "Stopping and waiting for HTTP servers"
I0924 11:25:15.707977 99028 internal.go:561] "Wait completed, proceeding to shutdown the manager"
Summarizing 1 Failure:
[FAIL] Integration tests Cache Getting objects ConfigMap [It] should return the object with a live read [envtest]
/Users/akutz/Projects/vmop/vmop/pkg/manager/test/cache_test.go:58
Ran 1 of 3 Specs in 7.299 seconds
FAIL! -- 0 Passed | 1 Failed | 0 Pending | 2 Skipped
--- FAIL: TestManager (7.30s)
FAIL
FAIL github.com/vmware-tanzu/vm-operator/pkg/manager/test 8.053s
FAIL It seems that controller-runtime does not fall-through to the API reader / bypass cache if any namespace mappings are present for an object. Is there not any way we can utilize
Thanks! |
That is correct. Some context:
Potential solutions
|
First of all, thank you @sbueringer!
Ironically, this is exactly what we used to do prior to CR introducing the Okay, I guess we need to go back to that then. Thanks again @sbueringer ! |
What does this PR do, and why is it needed?
This patch updates the manager cache for VM Operator so that ConfigMap/Secret resources from the kube-system and VM Op pod namespaces are cached, but ConfigMap/Secret resources in any other namespace are not cached.
This patch means controllers that access ConfigMap/Secret resources in these namespaces no longer need to create separate caches. Instead, all controllers may use the manager client unless for some other reason.
Which issue(s) is/are addressed by this PR? (optional, in
fixes #<issue number>(, fixes #<issue_number>, ...)
format, will close the issue(s) when PR gets merged):Fixes
NA
Are there any special notes for your reviewer:
The tests in
controllers/infra/secret/infra_secret_controller_intg_test.go
related to checking the value ofcalled
validates the expected behavior.Please add a release note if necessary: