You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am writing an operator managing a primary resource which has dependent resources. I am extending the CRUDKubernetesDependentResource and using the default SecondaryToPrimary mapper based on owner references.
In the same namespace, there may be other resources with the same name as my primary (but with different types!), and they may have secondary resources of the same type as the secondary resource my operator is managing (a ConfigMap for example).
What did you expect to see?
I expected the SecondaryToPrimaryMapper to take into account primary resource kind and attribute secondary resources correctly.
What did you see instead? Under which circumstances?
All secondary resources with an owner reference matching the name of the primary (but not necessarily the kind) get mapped to the primary, leading to an IllegalStateException being thrown because there is more than 1 secondary resource found.
Environment
Kubernetes cluster type:
GKE
$ Mention java-operator-sdk version from pom.xml file
4.9.1
$ java -version
openjdk version "21.0.3" 2024-04-16 LTS
OpenJDK Runtime Environment Corretto-21.0.3.9.1 (build 21.0.3+9-LTS)
OpenJDK 64-Bit Server VM Corretto-21.0.3.9.1 (build 21.0.3+9-LTS, mixed mode, sharing)
$ kubectl version
Client Version: v1.30.3
Kustomize Version: v5.0.4-0.20230601165947-6ce0bf390ce3
Server Version: v1.29.6-gke.1038001
Possible Solution
As a workaround, I provided my own implementation of SecondaryToPrimaryMapper using owner references:
Bug Report
What did you do?
I am writing an operator managing a primary resource which has dependent resources. I am extending the CRUDKubernetesDependentResource and using the default SecondaryToPrimary mapper based on owner references.
In the same namespace, there may be other resources with the same name as my primary (but with different types!), and they may have secondary resources of the same type as the secondary resource my operator is managing (a ConfigMap for example).
What did you expect to see?
I expected the SecondaryToPrimaryMapper to take into account primary resource kind and attribute secondary resources correctly.
What did you see instead? Under which circumstances?
All secondary resources with an owner reference matching the name of the primary (but not necessarily the kind) get mapped to the primary, leading to an IllegalStateException being thrown because there is more than 1 secondary resource found.
Environment
Kubernetes cluster type:
GKE
$ Mention java-operator-sdk version from pom.xml file
4.9.1
$ java -version
openjdk version "21.0.3" 2024-04-16 LTS
OpenJDK Runtime Environment Corretto-21.0.3.9.1 (build 21.0.3+9-LTS)
OpenJDK 64-Bit Server VM Corretto-21.0.3.9.1 (build 21.0.3+9-LTS, mixed mode, sharing)
$ kubectl version
Client Version: v1.30.3
Kustomize Version: v5.0.4-0.20230601165947-6ce0bf390ce3
Server Version: v1.29.6-gke.1038001
Possible Solution
As a workaround, I provided my own implementation of SecondaryToPrimaryMapper using owner references:
Additional context
The text was updated successfully, but these errors were encountered: