-
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
feat: Introducing GenericKubernetesResource #3185
Conversation
Can one of the admins verify this patch? |
12f40e2
to
4fb28ea
Compare
e4892c9
to
9775769
Compare
This change will be needed to rework/remove the raw websocket watch logic - it seems broken in the current state because it doesn't fully understand the events (http gone, updating the resource version, lists, etc.). |
76ef4a6
to
fc899a0
Compare
fc899a0
to
b75fe84
Compare
My intention is to at least finish the initial work on this by today (I already spent 2 days working on it and can't spend more time). This PR introduces the Generic Resource that can be further used in many areas of the client but those should be tackled separately. |
2a3c63b
to
83f6b63
Compare
Okay, I'll hold off on adopting this for now in the mock. In the meantime I've rebased #3156 to master, when you get a chance please review. |
83f6b63
to
319aa79
Compare
34560e3
to
bab9256
Compare
kubernetes-itests/src/test/java/io/fabric8/kubernetes/RawCustomResourceIT.java
Outdated
Show resolved
Hide resolved
...bernetes-model-core/src/main/java/io/fabric8/kubernetes/internal/KubernetesDeserializer.java
Show resolved
Hide resolved
bab9256
to
ee4650a
Compare
...etes-model-core/src/main/java/io/fabric8/kubernetes/api/model/GenericKubernetesResource.java
Outdated
Show resolved
Hide resolved
fb8bead
to
e167402
Compare
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
Hi @lburgazzoli, since (I think) you are an active user of the RawCustomResources, it would be very interesting to count with your review and check in case something is broken for you with the changes suggested in this PR. 🙏 |
@manusa I'll try to build the PR and use it in my project beginning of next week, my knowledge of the k8s client internals is too limited to give any valuable review. If there is an example that show how to use the new resource, I may take a look at it today to see if I spot something missing. |
Basically there is no way to explicitly use the new Resource (as of now). The partial purpose of this PR is for RawCustomResourceOperationsImpl instead of re-implementing everything from scratch (and leading to issues like some of the ones you reported (#3023, and indirectly #2929)) to use the regular base implementations by delegating its logic to the new So if you're still using the "unstructured" RawCustomResourceOperationsImpl ( This is also the base to any enhancement or feature we want to perform regarding #2929. |
ok, so I'll try to compile it and see if it breaks something |
e167402
to
fc292cf
Compare
SonarCloud Quality Gate failed. |
@manusa I've updated my operator to use the code from this PR and nothing seems to be broken, so LGTM |
Great, thx for trying it out. Merging 🚀 |
Description
Introduction of the GenericKubernetesResource
This class holds the minimum structure for any valid resource served by the Kubernetes API. i.e. A HasMetadata implementation with an
ObjectMeta metadata
field and a Map for any additional property/field.The main purpose of this class is to be able to Serialize/Deserialize any resource served by Kubernetes regardless of a specific type previously registered for that resource.
The Serializer now looks for any registered type for a given resource and in case none is found, the resource is deserialized as a GenericKubernetesResource. The immediate benefit is that deserialization will never fail.
This resource can be later on used in a specific
OperationSupport
implementation that will provide consistent operation support for any resource.RawCustomResourceOperationsImpl uses GenericKubernetesResourceOperationsImpl
This brings consistency to the client, but no specific behavioral changes should be noticed. Some changes might be noticed in case of the MockServer and white box testing, since some of the requests have changed, but the result should be no different.
The only major difference is that a
.get()
for a non-existent resource previously threw an Exception and now returns null (just like the rest of OperationSupport implementations for any other resource).Redundant methods have been marked as deprecated. We should consider removing them definitely after the next few releases.
Next steps
Improve
KubernetesClient#load
to support operations for GenericKubernetesResource. This means requesting the applicable CustomResourceDefinition from the cluster in order to infer the plural and scope of the managed resource.Type of change
test, version modification, documentation, etc.)
Checklist