-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Fully addressing static deserialization issues #4662
Conversation
b60e244
to
9a6fefe
Compare
Rebased and pulled out unrelated changes. This is much closer to being fully functional. General notes on these changes:
What still needs work:
What this will allow us to do:
|
851621a
to
0334f70
Compare
This is a little closer. The KubernetesDeserializer / class loading mechanism are still not exposed, but that should be straight-forward. Also the KubernetesSerialization constructor that takes an objectmapper could be refined - the logic that modifies the objectmapper could be moved to a separate method to be more usable with a quarkus ObjectMapperCustomizer. For now the Serialization class remains in use as it would be painful to fully refactor some of the other static api methods. At the very least we'll still have another static objectmapper in Serialization.
Other than that everything should be using the objectmapper provided to KubernetesSerialization. The methods on KubernetesSerialization try to encapsulate access to the objectmapper, but that can be relaxed if need be. The observation was that our existing code was using quite a few different ways to do parsing or serialization. The third bullet point above remains - it's TBD on how to handle the direct usage of a non-modified objectmapper and KubernetesDeserializer. For now the static state has been removed from KubernetesDeserializer, but that means that each instance will need to redo the classloading. |
kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/utils/Serialization.java
Outdated
Show resolved
Hide resolved
SonarCloud Quality Gate failed. |
Hi @shawkins, |
Fabric8 team removed[1][2] constructors, which we were using to create Openshift client Switched to other methods. This change was brought to Quarkus with this update[3] [1] fabric8io/kubernetes-client@6d7db80#diff-92a1266d167b46838301a64f043de2895376ebf7ec810e7769d641d2fed6f511L227-L246 [2] fabric8io/kubernetes-client#4662 [3] quarkusio/quarkus#33767
Follow up to [1] caused by the same breaking changes[2]. Added some tests to cover affected scenarios from the TS. [1] quarkus-qe#803 [2] fabric8io/kubernetes-client#4662
See [1] and [2] for details. [1] quarkus-qe#803 [2] fabric8io/kubernetes-client#4662
Description
Builds on #4651 to show where these changes are headed. This is in a rough state, so it's just representative and not fully working.
To recap - clone, convertValue, and unmarshal with a type that transitively references KubernetesDeserializer are all relying on static KubernetesDeserializer state. Specifying a non-KubernetesResource type like Map, should be fine - however, it still seems like a good idea to aggregate all of the calls onto the new class rather than leaving some static calls.
The other Serialization methods rely on static objectmappers, at least the yaml mapper was identified as unnecessarily holding state (more on that below).
This change attempts to remove the static KubernetesDeserializer state and make more about the ObjectMapper injectable. We will do this by introducing a KubernetesSerialization class to represent state-fully how to do our serialization operations. With a few other tweaks we can give full control over what classes are known - of course still offering the classloader based loading mechanism by default.
The idea is that we'll associate a KubernetesSerialization with the client via the KubernetesClientBuilder. That will then get passed around appropriately. Instead of the KubernetesDeserializer holding a static mapping, there will instead be an instance held by KubernetesSerialization, which is associated with its objectmapper for use when a KubernetesDeserializer is requested.
Other thoughts:
@manusa @rohanKanojia @metacosm let me know if this seems worth following through on.
Type of change
test, version modification, documentation, etc.)
Checklist