-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
fix #4206: ensuring null won't be returned from kubernetesdeserializer #4263
Conversation
Kudos, SonarCloud Quality Gate passed! |
@manusa @rohanKanojia based upon our meeting we agree that mapping raw to HasMetadata is not good. It also creates a potentially odd set of builder methods as sundrio will assume the only valid types are the concrete types in the module and in the BuildableReferences. Raw should instead be any valid structured content. My motivation to use the GenericKubernetesResource however was that it was the easiest way to preserve this content. if you run something like:
You'll see that the unsupportedConfigOverrides are lost when they lack a kind/apiVersion. That should be occurring in all such places like NamedExtension.extension, which seems to already exist in the Configs used in our test cases. So if we don't want to use GenericKubernetesResource to conform to the existing mapping, then we'll have to change the generator / mapping logic. As for the original issue #4206 - that could be handled separately for now just by considering the top-level object only, but it will of course get fixed if we generally handle the raw case - the Serialization.unmarshall would return a map of maps or whatever we think is appropriate for representing raw content when the root object lacks kind/apiVersion information. |
Right now the mapper has inconsistent handling for this, which is the worst part. So in general, the following applies: kubernetes-client/kubernetes-model-generator/pkg/schemagen/generate.go Lines 180 to 181 in 296ec4f
But you can also find: kubernetes-client/extensions/open-cluster-management/generator-agent/cmd/generate/generate.go Line 63 in 9f1a569
kubernetes-client/kubernetes-model-generator/openshift-model-machine/cmd/generate/generate.go Line 73 in a1b6863
and a few more... And as I write this I'm recalling conversations around this topic and the specific mapping of rawExtension to Map precisely to avoid this problem. (#2073 #2335) There also seems to be an internal issue about this d511cc8 |
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.
LGTM apart from typo (see comment).
...bernetes-model-core/src/main/java/io/fabric8/kubernetes/internal/KubernetesDeserializer.java
Outdated
Show resolved
Hide resolved
@manusa @metacosm here's an update to a hybrid / tactical solution. The deserializer will always return a generic, but we'll make a top level check to ensure that only valid generics are returned - which will satisfy #4206. This will allow for the HasMetadata mapping of raw to continue to work - then for a major release, or whenever we're comfortable with the breaking change, the mappings can be fixed. |
Signed-off-by: Marc Nuri <marc@marcnuri.com>
Kudos, SonarCloud Quality Gate passed! |
Description
Fix #4206
This is to address #4206. We cannot throw an exception as it appears that the Config parsing has embedded HasMetadata (extensions) references, which lack type information. So instead we'll return a generic resource - that should ensure round-trip parse/serialization is also correct.
Type of change
test, version modification, documentation, etc.)
Checklist