-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
🐛 RESTMapper: don't treat non-existing GroupVersions as errors #2425
🐛 RESTMapper: don't treat non-existing GroupVersions as errors #2425
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.
Needs 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. Instructions 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 |
@@ -166,8 +167,10 @@ func (m *mapper) addKnownGroupAndReload(groupName string, versions ...string) er | |||
if err != nil { | |||
return err | |||
} | |||
for _, version := range apiGroup.Versions { | |||
versions = append(versions, version.Version) | |||
if apiGroup != nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this check here? If apiGroup is nil, the range would throw a panic
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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. Instructions 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
RESTMapper
implementation to properly handle cases where an API Group / GroupVersion is not present in the system. Clients expectNo{Kind,Resource}MatchErrors
in this case.The first commit increases the accuracy of the
RESTMapper
tests to verify the described expectations.The second commit implements the actual fix.
/label tide/merge-method-squash
Fixes #2424