-
Notifications
You must be signed in to change notification settings - Fork 184
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
JOSDK doesn't support use of CRUDKubernetesDependentResource(with GC) when owner resource is cluster scoped #2398
Comments
Hi @arpitchaudhary , thx for reporting, The way to handle this (in v4.x.x) is to implement the and just call the prepared mapper for this, see: Line 60 in 94d2107
where the cluster scoped flag should be |
This could be done to some extent automatically, will take a look for v5, since other things related to this are changing. |
Thanks for the quick reply. We currently extended |
There is only minimal downside, |
see sample how to set (for v4.x.x) |
This is already fixed in v5 |
Bug Report
What did you do?
What did you expect to see?
I expected reconciliation to succeed and any updates in MyCustom resource to lead to updating role bindings as needed based on spec updates in MyCustom resource.
What did you see instead? Under which circumstances?
This lead to error while reconciliation:
This is because the operator tries to recreate the role bindings even when they already exist during second reconciliation or when owner resource (MyCustom) is updated . This happens because:
context.getSecondaryResources(RoleBinding.class);
returns empty set even when role bindings exist.Mapper.SecondaryToPrimaryMapper
(link) only considering owner from same namespace. This is because CRUDKubernetesDependentResource is garbage collected(link)https://github.com/operator-framework/java-operator-sdk/blob/main/operator-framework-core/src/main/java/io/javaoperatorsdk/operator/processing/dependent/kubernetes/KubernetesDependentResource.java#L89-L90So, even though ownerRef allows use of cluster scoped resource, JOSDK assumes that the owner is from the same namespace only.
Environment
Kubernetes cluster type:
kind version 0.19.0-alpha+e28a39297dbd55
$ Mention java-operator-sdk version from pom.xml file
Tried with 4.8.0 and 4.9.0
$ java -version
openjdk 17.0.9 2023-10-17 LTS
$ kubectl version
Client Version: version.Info{Major:"1", Minor:"21+", GitVersion:"v1.21.1-rc.0.41+e338d4e93d422d", GitCommit:"e338d4e93d422d796f8e692289ccbcbede94c712", GitTreeState:"clean", BuildDate:"2021-04-30T22:16:08Z", GoVersion:"go1.16.2", Compiler:"gc", Platform:"darwin/amd64"}
Server Version: version.Info{Major:"1", Minor:"27", GitVersion:"v1.27.3", GitCommit:"25b4e43193bcda6c7328a6d147b1fb73a33f1598", GitTreeState:"clean", BuildDate:"2023-06-14T09:47:40Z", GoVersion:"go1.20.5", Compiler:"gc", Platform:"linux/arm64"}
Possible Solution
Additional context
Workaround: Use
CRUDNoGCKubernetesDependentResource
instead ofCRUDKubernetesDependentResource
The text was updated successfully, but these errors were encountered: