-
Notifications
You must be signed in to change notification settings - Fork 220
fix: make it possible to have read-only dependents #956
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
Conversation
Isn't read only dependent just an informer? I would not change the AbstractDependentResource, would rather extend |
I knew you would say that and I don't agree. 😄 |
This should be about the right abstractions. It would not be deeper, wider, this is why we have |
...ain/java/io/javaoperatorsdk/operator/api/reconciler/dependent/AbstractDependentResource.java
Outdated
Show resolved
Hide resolved
If it looks like a dependent but don't behave like a dependent, then it is not a dependent. I think a definition of what is a dependent resource should be settled. To me
From what I understand of the actual Even if it is abstract away with noop default, it is weird to have a reconcile and delete method and resource that don't need it. To me, it is more like a LookupResource that can be added to dependents ?
|
I agree with this basically. This is also a matter of definition, what is a dependent resource, but this when needs to just read is not really a dependent resource, true. At least not feels like it. It could be defined as a super interface actually to the dependent resource, maybe just having The one reason that on So right modeling is essential here. @metacosm wants to limit the hierarchy and that is not a bad aspect of the problem. On the other hand we should capture these notions in the domain model. And for now it does not seems very extreme with the mentioned abstractions. (see model below) I think first we should think in object models, then have an annotation structure defined/handled as secondary, since that is limited. There are problem which are essentially harder to do in the background. I would like to have this api with annotations, ideally this whole structure is declarative, but that should be the second step. Like for example in standalone mode if we need a status of a dependent resource as an input of an other it really can just reference the dependent resource as an attribute in class. For annotations we need additional mechanisms in the background what gives more complexity. So would propose: classDiagram
ReadableResource <|-- DependentResource
DependentResource <|-- AbstractDependentResource
DependentResource <|-- EditableResource
AbstractDependentResource <|-- KuberentesDependentResource
But I don't have strong opinion on Maybe |
Co-authored-by: Sébastien CROCQUESEL <[email protected]>
SonarCloud Quality Gate failed. |
The deeper the class hierarchy the more fragile the architecture becomes and the more complex it is to configure things via annotations. So yes, a read-only Kubernetes dependent is essentially an informer but this allows to very quickly create an informer using simply an annotation instead of figuring out which class to use among 5-6 of them and have to manually wire it. Of note, the initial implementation used to split the different behaviors by interfaces where create, update, delete were traits that you could add to your dependent. |
Maybe it's just me, but for me is much more easy to understand a clean class hierarchy then check why a functionality is hacked to an abstraction what serves a completely different purpose. Like from now on if somebody wants to create a read only resource (for an external resource let's say) will have extend implement AbstractDependentResource, override In addition to that now every KubernetesDependentResource Also why it is harder to configure? it's anyway a new subclass, where just a config needs to be passed. Can provide an alternate implementation to show how I mean, we can compare it. With this approach, how I meant it originally: classDiagram
DependentResource <|-- GenericDependentResource
DependentResource <|-- EditableResource
DependentResource <|-- ReadOnlyDependentResource
GenericDependentResource <|-- KuberentesDependentResource
Having probably an AbstractKubernetesResource to have a subclass for versions of Kubernernetes resoruces. I agree that this has it's negative sides too. So maybe it's really make sense to compare prototypes. Nevertheless this is an interesting topic, so thx to initiate and starting on it. |
Isn't the reconciler v2 refactoring all about using trait interface ? Class hierarchy are a pain when we tends to put things in the hierarchy that should not. But the same fragility will happens when building fat class. Here, Interface Segregation principle is violated and to me, while it seems to be a quick win now, it certainly become a pain latter.
Confusing enough,
I like your last diagram. Even if for me DependentResource may be an empty marker interface to ease configuration. Looking at DependentResourceManager, it is just a delegation pattern over a collection. Maybe complexity should be there. Manager is the glue between the Roughly,
|
Created a prototype with class hierarchy: It ended up quite ok. Especially when for a polling (readonly) dependent resource. But when created an abstract Kuberentes Resource, turned out also quite reasonable for the sub-classes, and it's quite clear. The editable at the end added as a feature flag to the Pls take a look, what do you think about this way. |
Not really, but there were changes regarding that, too. It was more about how we address resources in event sources, using informers for main event source (also for caching) etc.
One of the design aspects however is to able to use the DependentResources in standalone mode: |
Replaced by #963. |
Fixes #955