-
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
🌱 GVKForObject should handle multiple GVKs in Scheme gracefully #2192
🌱 GVKForObject should handle multiple GVKs in Scheme gracefully #2192
Conversation
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: vincepri The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
bc9f14f
to
48ec279
Compare
pkg/client/apiutil/apimachinery.go
Outdated
return schema.GroupVersionKind{}, fmt.Errorf( | ||
"multiple group-version-kinds associated with type %T, refusing to guess at one", obj) | ||
"multiple GroupVersionKinds associated with type %T within the Scheme: this can happen when a type is registered for multiple GVKs at the same time, callers can either fix their type registration to only register it once, or specify the GroupVersionKind to use for object passed in; refusing to guess at one: %q", obj, gvks) |
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.
Nit/thought: Should we say "go type" instead of "type"? I think it might help people understand what has happened ... I know I sometimes conflate kind vs resource vs type, and it's that association that has gone wrong here.
return gvk, 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.
Maybe log if we reject for this reason? It's unlikely, but I would be very confused if I ever set the wrong GVK here which was then silently ignored...
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.
ptal, refactored to wrap errors differently depending on what we have
Thanks for doing this @vincepri ... I like it and I think it's a reasonable approach. Had some suggestions on being even more verbose, but this is already a great improvement :-) |
48ec279
to
67d3283
Compare
Looks really good - thanks @vincepri /lgtm |
/hold for other reviewers @alvaroaleman |
/cherry-pick release-0.14 |
@vincepri: once the present PR merges, I will cherry-pick it on top of release-0.14 in a new PR and assign it to you. In response to this:
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. |
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.
Just a nit otherwise lgtm
- If the user sets the GVK, make sure that's in the list of the GVK returned from the Scheme. - Always print out the multiple GVKs when erroring out - Add more comments on where to find more information about this issue Signed-off-by: Vince Prignano <[email protected]>
67d3283
to
ea10051
Compare
/retest |
1 similar comment
/retest |
/lgtm |
/hold cancel |
@vincepri: new pull request created: #2202 In response to this:
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. |
Signed-off-by: Vince Prignano [email protected]