kubernetes: Decoding should not clear apiVersion/kind
What would you like to be added: When using a typed client, decoding to a versioned struct (not an internal API type), the apiVersion/kind information returned from the server should not be dropped.
Why is this needed:
The GroupVersionKind()
method included in the ObjectKind interface is largely useless when dealing with arbitrary runtime.Object instances, since typed instances drop this information here:
This is the decoder used when a client requests a decoder that does not do conversion:
I could see clearing group/version/kind information when converting to an internal version, but I don’t see the benefit of stripping it on decode if we’re only dealing with a versioned struct.
/sig api-machinery /cc @smarterclayton
Note that https://github.com/kubernetes/kubernetes/issues/3030 still needs to be resolved before apiVersion/kind could be depended on for individual objects for all API responses, but this would at least solve the issue with an update of an object clearing the apiVersion/kind in an update response (xref https://github.com/kubernetes-sigs/controller-runtime/issues/526)
About this issue
- Original URL
- State: open
- Created 5 years ago
- Reactions: 41
- Comments: 17 (10 by maintainers)
Commits related to this issue
- Allow users to specify their own custom NegotiatedSerializer In the current implementation, it's impossible to use a different serializer rather than the default one. In some cases, it might be usefu... — committed to vincepri/kubernetes by vincepri 3 years ago
- Allow users to specify their own custom NegotiatedSerializer In the current implementation, it's impossible to use a different serializer rather than the default one. In some cases, it might be usefu... — committed to vincepri/kubernetes by vincepri 3 years ago
- Use resource descriptor GVK for `NewSession` (#120) Description of changes: Some version of K8s do not reliably return `TypeMeta` information when you call `apiReader.Get()` (see https://github.com/... — committed to aws-controllers-k8s/runtime by RedbackThomson a year ago
it is still an issue on the latest version 😃
/reopen
I doubt a PR to cluster-api fixed this
Is there a real million stone for this issue? I see you moved this from v1.19 to v1.20
Although typed resource is already known to user, it’s a bit weird to explicitly remove the GVK from de-serialized struct. The explicit behavior sometimes makes things harder, eg: Printing struct Kind and version, without filled TypeMeta, I need reflect package to do so. Any comments or suggestion?