🐛 RESTMapper: don't treat non-existing GroupVersions as errors#2425
🐛 RESTMapper: don't treat non-existing GroupVersions as errors#2425timebertt wants to merge 2 commits intokubernetes-sigs:mainfrom
Conversation
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: timebertt The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
|
Hi @timebertt. Thanks for your PR. I'm waiting for a kubernetes-sigs member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
|
/ok-to-test |
| } | ||
| for _, version := range apiGroup.Versions { | ||
| versions = append(versions, version.Version) | ||
| if apiGroup != nil { |
There was a problem hiding this comment.
Why is this check here? If apiGroup is nil, the range would throw a panic
There was a problem hiding this comment.
Exactly, if the queried group name cannot be found, apiGroup is nil and the next line will cause a nil pointer dereference.
There was a problem hiding this comment.
Alternatively, we could make mapper.apiGroups a map[string]metav1.APIGroup so that we don't have to check for nil pointers.
There was a problem hiding this comment.
Could we have findAPIGroupByName return a well-known not found error, and catch it here instead of returning nil, nil?
| // Don't return an error here if the API group is not present. | ||
| // The reloaded RESTMapper will take care of returning a NoMatchError. | ||
| return m.apiGroups[groupName], nil |
|
We might need to categorize this as a breaking change, rather than a bug? |
Hmm, it's hard for me to draw the line here. As such, you are right, this is a breaking change. However, this is only because a previous breaking change incorrectly altered the behavior. |
|
/retest |
- Latest restmapper implementation doesnot handle cases where an API Group / GroupVersion is not present in the system. In such cases Clients expect No{Kind,Resource}MatchErrors.
- Upstream fix is already open kubernetes-sigs/controller-runtime#2425.
- Revert this commit once the fix is available.
- Latest restmapper implementation doesnot handle cases where an API Group / GroupVersion is not present in the system. In such cases Clients expect No{Kind,Resource}MatchErrors.
- Upstream fix is already open kubernetes-sigs/controller-runtime#2425.
- Revert this commit once the fix is available.
- Latest restmapper implementation doesnot handle cases where an API Group / GroupVersion is not present in the system. In such cases Clients expect No{Kind,Resource}MatchErrors.
- Upstream fix is already open kubernetes-sigs/controller-runtime#2425.
- Revert this commit once the fix is available.
- Latest restmapper implementation doesnot handle cases where an API Group / GroupVersion is not present in the system. In such cases Clients expect No{Kind,Resource}MatchErrors.
- Upstream fix is already open kubernetes-sigs/controller-runtime#2425.
- Revert this commit once the fix is available.
- Latest restmapper implementation doesnot handle cases where an API Group / GroupVersion is not present in the system. In such cases Clients expect No{Kind,Resource}MatchErrors.
- Upstream fix is already open kubernetes-sigs/controller-runtime#2425.
- Revert this commit once the fix is available.
- Latest restmapper implementation doesnot handle cases where an API Group / GroupVersion is not present in the system. In such cases Clients expect No{Kind,Resource}MatchErrors.
- Upstream fix is already open kubernetes-sigs/controller-runtime#2425.
- Revert this commit once the fix is available.
- Latest restmapper implementation doesnot handle cases where an API Group / GroupVersion is not present in the system. In such cases Clients expect No{Kind,Resource}MatchErrors.
- Upstream fix is already open kubernetes-sigs/controller-runtime#2425.
- Revert this commit once the fix is available.
- Latest restmapper implementation doesnot handle cases where an API Group / GroupVersion is not present in the system. In such cases Clients expect No{Kind,Resource}MatchErrors.
- Upstream fix is already open kubernetes-sigs/controller-runtime#2425.
- Revert this commit once the fix is available.
|
@timebertt any progress on this? |
|
PR needs rebase. DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
|
I may be off, but wasn't this fixed with #2472? |
|
Yes |
I was wrong, this is still needed, as with non existing CRDs you would get this err |
/kind bug
This PR fixes the new
RESTMapperimplementation to properly handle cases where an API Group / GroupVersion is not present in the system. Clients expectNo{Kind,Resource}MatchErrorsin this case.The first commit increases the accuracy of the
RESTMappertests to verify the described expectations.The second commit implements the actual fix.
/label tide/merge-method-squash
Fixes #2424