-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
Kubectl.apply fails while GenericKubernetesApi works for ClusterRole #3518
Comments
You're getting a 404 on the apply. Does this object exist currently in the cluster? Or are you trying to create it for the first time? My first guess is that |
Hi Brendan, it's the first I create it. |
Also, I see |
When you say that it works for Role, does it successfully create new Role resources that didn't previously exist? |
The Apply code is just calling ServerSide apply, so we may need to special case that code if it returns a 404. |
(sorry for lots of little questions :) Can you try |
No problem Brendan, I've already tried lots of them. |
Ok, thanks for the details, this is odd. But I think I may have figured it out. We only supply the type, not the list type when we get the generic API in My guess is that the class for the openshift ClusterRole is being discovered before the class for the standard ClusterRole and that is confusing things. If you are willing it would be super useful if you could recompile the library with some logging around that code location to verify that's what's going on, that's great. If not I can try to add some defensive code around that location that would fix the problem. |
Hi Brendan, I'm happy to help anyway I can. apiTypeClass = class io.kubernetes.client.openapi.models.V1ClusterRole The resolved groupVersionResource seems to be the problem, containing: resource = clusterroles As I can see in Any thoughts on how can I address this? Thanks a lot for your help. |
Ok, there must be some issue in the map key comparison that is causing a problem. I can try to reproduce this when I get some time, but if you have time to explore and send a PR that'd be great too. |
I'd love to send a PR, I'm adding a test to reproduce the bug and will try to fix it. |
The Kubernetes project currently lacks enough contributors to adequately respond to all issues. This bot triages un-triaged issues according to the following rules:
You can:
Please send feedback to sig-contributor-experience at kubernetes/community. /lifecycle stale |
Hi, sorry for the delay in getting back to this, but summer has been a bit crazy at work.
The fix itself is quite easy, just modifying the BiDirectionalMap in ModelMapper to take into account we can have many GroupVersionResource for a given object class instead of only one:
However, this is a deep change that will impact too |
/remove-lifecycle stale |
/lifecycle-frozen @agustinventura apologies for not following up on this sooner. I think that the change you propose is ok. We'll need to validate group/version alongside kind. |
Hi Brendan, sorry for the delay in getting back to this.
To this:
This works great and now we have both maps synchronized, being able to get many values for the same key, but also many keys for the same value.
Now must return a set of
And this, in turn affects the user facing API, for example, in Kubectl line 264 we got
This would become:
So, once I get the What do you think? |
Describe the bug
When creating a ClusterRole Kubectl.apply returns error while GenericKubernetesApi creates it.
Client Version
18.0.0 - 21.0.0-legacy
Kubernetes Version
1.27 (OpenShift 4.14.16)
Java Version
Java 21
To Reproduce
Given a ClusterRole in clusterrole.yaml file:
And a kubeconfig for an OpenShift 4.14.16 in kubeconfig file, load both files and try to apply ClusterRole:
This will return the following error:
However, if ClusterRole is created using GenericKubernetesApi it succeeds:
If applying clusterrole.yaml with kubectl cli it suceeds too:
Expected behavior
Kubectl.apply should create ClusterRole.
Server (please complete the following information):
Additional context
This looks like some weird interaction with OpenShift, as we found it upgrading from 4.12.25 to 4.14.16 and didn't have this kind of issues with other platforms such as EKS. The error itself returns group authorization.openshift.io instead of rbac.authorization.k8s.io pointing to some specific OpenShift logic but however it is strange that kubectl cli and the GenericKubernetesApi works and only fails when using kubectl Java client.
We also tried to add the group in the error to ModelMapper:
But returns the same error.
It fails too for RoleBinding objects but not for Role or ClusterRoleBinding ones.
The text was updated successfully, but these errors were encountered: