Repository navigation
Conversation
…t encoding with multiple kinds registered for the same go type
|
Skipping CI for Draft Pull Request. |
|
Adding the "do-not-merge/release-note-label-needed" label because no release-note block was detected, please follow our release note process to remove it. 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-sigs/prow repository. |
|
Please note that we're already in Code Freeze for the upcoming v1.37.0 release. Adding the milestone to this PR is strictly prohibited without proper approval. If this PR needs to be included in the v1.37.0 release:
We're also in Test Freeze for the Fast forwards are scheduled to happen every 6 hours, whereas the most recent run was: Wed Aug 12 18:39:00 UTC 2026. |
|
This issue is currently awaiting triage. If a SIG or subproject determines this is a relevant issue, they will accept it by applying the The 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-sigs/prow repository. |
|
|
||
| // LogResponseObject fills in the response object into an audit event. The passed runtime.Object | ||
| // will be converted to the given gv. | ||
| func LogResponseObject(ctx context.Context, obj runtime.Object, gv schema.GroupVersion, s runtime.NegotiatedSerializer) { |
There was a problem hiding this comment.
There are a few signatures like this one that can be widened to accept the interface runtime.GroupVersioner instead of schema.GroupVersion. These parameters were ultimately used as an Encoder's GroupVersioner anyway.
| Kind schema.GroupVersionKind | ||
| Resource schema.GroupVersionResource | ||
| Kind schema.GroupVersionKind | ||
| ResourceVersioner ResourceGVK |
There was a problem hiding this comment.
Or a sibling ListKind?
There was a problem hiding this comment.
what does Kind contain for list operations? Pod or PodList?
| // the caller may return a flag indicating whether the result should be flushed as writes occur | ||
| // and a content type string that indicates the type of the stream. | ||
| // If a null stream is returned, a StatusNoContent response wil be generated. | ||
| InputStream(ctx context.Context, apiVersion, acceptHeader string) (stream io.ReadCloser, flush bool, mimeType string, err error) |
There was a problem hiding this comment.
I didn't find any real implementations using this parameter, so removing it was the simplest option. I don't think this approach requires breaking this interface, though.
| var _ rest.GroupVersionKindProvider = &multiKindStorage{} | ||
| var _ rest.GroupVersionListKindProvider = &multiKindStorage{} | ||
|
|
||
| func (s *multiKindStorage) GroupVersionKind(containingGV schema.GroupVersion) schema.GroupVersionKind { | ||
| return containingGV.WithKind(s.kind) | ||
| } | ||
|
|
||
| func (s *multiKindStorage) GroupVersionListKind(containingGV schema.GroupVersion) schema.GroupVersionKind { | ||
| return containingGV.WithKind(s.kind + "List") | ||
| } |
There was a problem hiding this comment.
Without these, today:
F0806 13:38:16.417302 805429 openapi.go:46] Failed to build open api spec for root: duplicate Operation ID listTestgroupV1NamespacedFoo for path
/apis/testgroup/v1/namespaces/{namespace}/bars and /apis/testgroup/v1/namespaces/{namespace}/foos
and
{
"kind": "APIResourceList",
"apiVersion": "v1",
"groupVersion": "testgroup/v1",
"resources": [
{
"name": "bars",
"singularName": "bar",
"namespaced": true,
"kind": "Foo", <--------------
"verbs": [
"get",
"list"
]
},
{
"name": "foos",
"singularName": "foo",
"namespaced": true,
"kind": "Foo",
"verbs": [
"get",
"list"
]
}
]
}
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: benluddy 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 |
| } | ||
| if isLister { | ||
| if listKindProvider, ok := storage.(rest.GroupVersionListKindProvider); ok { | ||
| reqScope.ResourceVersioner.ListKind = listKindProvider.GroupVersionListKind(a.group.GroupVersion) |
There was a problem hiding this comment.
I don't think it would be safe to assume the "singular kind + 'List'" convention for all API servers.
| @@ -395,7 +395,6 @@ func (storage *SimpleRESTStorage) List(ctx context.Context, options *metainterna | |||
| } | |||
|
|
|||
| type SimpleStream struct { | |||
There was a problem hiding this comment.
nit: add a ResourceStreamer type assertion on this bit to directly catch the signature change?
| out, flush, contentType, err := stream.InputStream(req.Context(), req.Header.Get("Accept")) | ||
| if err != nil { | ||
| ErrorNegotiated(err, s, gv, w, req) | ||
| ErrorNegotiated(err, s, schema.GroupVersion{}, w, req) |
There was a problem hiding this comment.
passing schema.GroupVersion{} for GV here looks iffy
if callers like WriteObjectNegotiated have the groupversion today, switching the signature to GroupVersioner would make sense rather than throwing away that info
eitherwise, using either metav1.Unversioned or populating a groupversion out of the RequestInfo APIGroup/APIVersion pulled from the context might make more sense
| case (target.Kind == "PartialObjectMetadata" || target.Kind == "PartialObjectMetadataList" || target.Kind == "Table") && | ||
| (target.GroupVersion() == metav1beta1.SchemeGroupVersion || target.GroupVersion() == metav1.SchemeGroupVersion): | ||
| return *target, apihelpers.GetMetaInternalVersionCodecs(), true | ||
| return target.GroupVersion(), apihelpers.GetMetaInternalVersionCodecs(), true |
There was a problem hiding this comment.
why throw away the kind info here? I thought we intended to make GVK implement GroupVersioner
|
|
||
| func (r ResourceGVK) KindForGroupVersionKinds(kinds []schema.GroupVersionKind) (schema.GroupVersionKind, bool) { | ||
| for _, k := range kinds { | ||
| if k == r.Kind || (!r.ListKind.Empty() && k == r.ListKind) { |
There was a problem hiding this comment.
nit, hoist !r.ListKind.Empty() outside the loop
| } | ||
| for _, k := range kinds { | ||
| if k.Group == r.Kind.Group && k.Version == r.Kind.Version { | ||
| return k, true |
There was a problem hiding this comment.
returning a kind other than r.Kind.Kind is odd, right? what happens if we don't have this fallback? same question below for the group-only match
| // type is registered under multiple Kind names in the same GroupVersion. | ||
| type ResourceGVK struct { | ||
| Kind schema.GroupVersionKind | ||
| ListKind schema.GroupVersionKind |
There was a problem hiding this comment.
storing a fully-qualified ListKind makes it possible for ListKind to not match the group or version of Kind (which would be weird) ... think about how to make that mismatch impossible
| Kind schema.GroupVersionKind | ||
| Resource schema.GroupVersionResource | ||
| Kind schema.GroupVersionKind | ||
| ResourceVersioner ResourceGVK |
There was a problem hiding this comment.
what does Kind contain for list operations? Pod or PodList?
|
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-sigs/prow repository. |
What type of PR is this?
What this PR does / why we need it:
Which issue(s) this PR is related to:
Special notes for your reviewer:
Does this PR introduce a user-facing change?
Additional documentation e.g., KEPs (Kubernetes Enhancement Proposals), usage docs, etc.: