-
Notifications
You must be signed in to change notification settings - Fork 1.2k
incorrect check for duplicate controller names #2937
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
Comments
You can disable the name verification (which prevents the name being added to the set of previously seen names). This PR landed the change #2918 _, err = controller.New("c1", m, controller.Options{Reconciler: rec, SkipNameValidation: ptr.To(true)}) |
This is not a particularly appealing option. I'd rather not mix my test code (where the controllers need to skip validation) and production code (where the validation should be executed) If you have a project which follows the Kubebuilder book, you're very likely to use the builder pattern, and not have an easy way of injecting configuration to all controllers |
It is also an option on the manager, setting it there will disable it for all controllers managed by this manager. |
@alvaroaleman , can you indicate where that option resides? i assumed it would be part of this structure, but it is not the case: controller-runtime/pkg/manager/manager.go Lines 100 to 107 in 610870e
LE: the configuration is going through the controller-runtime/pkg/manager/manager.go Lines 267 to 270 in 610870e
|
|
- Also bumped controller-runtime to v0.19.3 - Updated Watch function and predicates. - unit tests: Added SkipNameValidation:true when creating new controller-runtime manager to avoid "unique controller name" check [0] - Fixed lint issues due to go bump: - deprecated function PollImmediate [0] kubernetes-sigs/controller-runtime#2937 Signed-off-by: Ram Lavi <[email protected]>
- Also bumped controller-runtime to v0.19.3 - Updated Watch function and predicates. - unit tests: Added SkipNameValidation:true when creating new controller-runtime manager to avoid "unique controller name" check [0] - Fixed lint issues due to go bump: - deprecated function PollImmediate [0] kubernetes-sigs/controller-runtime#2937 Signed-off-by: Ram Lavi <[email protected]>
- Also bumped controller-runtime to v0.19.3 - Updated Watch function and predicates. - unit tests: Added SkipNameValidation:true when creating new controller-runtime manager to avoid "unique controller name" check [0] - Fixed lint issues due to go bump: - deprecated function PollImmediate [0] kubernetes-sigs/controller-runtime#2937 Signed-off-by: Ram Lavi <[email protected]>
@AndreiBarbuOz, I encountered the same error when running multiple controllers that reconcile the same object.
My workaround was to assign the controllers a unique name: ctrl.NewControllerManagedBy(mgr).
Named(r.Name()). // this assigns the controller a unique name
For(&MyType{}).
Complete(r) Can you use the test name as your controller name to avoid the conflict? - _, err = controller.New("c1", m, controller.Options{Reconciler: rec})
+ _, err = controller.New(t.Name(), m, controller.Options{Reconciler: rec}) |
Repro steps
Add the following test:
Expected result
Tests pass
Actual result
Tests fail
Additional info
controller-runtime seems to have implemented a uniqueness check based on global state with no way to reset the global state for tests :(
The text was updated successfully, but these errors were encountered: