Hello,
Seems like there's an issue with the KubernetesMockServer and the KubernetesAttributeExtractor#extract method.
I've registered a Custom Resource using fabric8 client and I'm testing the ability to create and retrieve the custom resource using the KubernetesMockServer.
The custom resource name is EntandoBundleRelease and the plural version is entandobundlereleases
I have a test where I'm able to create a new custom resource with the mock server but is not possible to retrieve the same custom resource due to an issue with the extract method I've reported above
My test class:
https://github.com/entando-k8s/entando-k8s-custom-model/blob/3febd76d453db6a4a8b5d5dda76d2639fd761f71/src/test/java/org/entando/kubernetes/model/AbstractEntandoBundleReleaseTest
On line 81 I'm able to create the custom resource successfully, but assertion fails on line 87 because the client is not able to find the custom resource using its name and namespace.
The problem is that when trying to find the custom resource from the in-memory database of the mock-server, the 'singularization' of the kind is not working properly
This is the line not working in this case (and others probably)
if (kind.endsWith("ses")) {
kind = kind.substring(0, kind.length() - 2);
}
So in my case instead of returning entandobundlerelease, it returns entandobundlereleas and therefore the match with registered resources fails and I get a 404 out of the KubernetesMockServer.
This problem could happen in many other cases, e.g CustomDatabase - customdatabases
@Kerruba : Are you facing this on v4.9.1?
@Kerruba : Could you please create a quick PR to fix this issue?
@rohanKanojia thanks for your response. The problem is that establishing an algorithm converting plural names to singular names can get really tricky. So whereas the existing algorithm works 100% accurately with the standard Kubernetes resources, it is nigh impossible to put an algorithm in place that works with all possible Custom resources kinds. The solution may be a bit more complicated, such as
This would therefore be a bit more tricky than just fixing a name conversion algorithm. We have implemented a hack locally so it is not a blocker for us at all, but it is probably worth looking into an elegant solution for custom resources going forward
This issue has been automatically marked as stale because it has not had any activity since 90 days. It will be closed if no further activity occurs within 7 days. Thank you for your contributions!
Most helpful comment
@rohanKanojia thanks for your response. The problem is that establishing an algorithm converting plural names to singular names can get really tricky. So whereas the existing algorithm works 100% accurately with the standard Kubernetes resources, it is nigh impossible to put an algorithm in place that works with all possible Custom resources kinds. The solution may be a bit more complicated, such as
This would therefore be a bit more tricky than just fixing a name conversion algorithm. We have implemented a hack locally so it is not a blocker for us at all, but it is probably worth looking into an elegant solution for custom resources going forward