-
Notifications
You must be signed in to change notification settings - Fork 219
Question & Opinion) ResourceController's init(EventSourceManager) method feels a bit vague. #615
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
Comments
Hi @heesuk-ahn, I agree with you that the intent of the |
@heesuk-ahn thx for the feedback!! To have access to this class is essential, to get access to the caches related to the custom resource, if we could separate/segragate that maybe access some abstracted access in the context for a cache interface? Then this might make sense.
|
Looking at the architecture diagram of Kubebuilder https://book.kubebuilder.io/architecture.html, there is a distinction between the Controller and the Reconciler, in the java operator sdk we are conflating the two concept in a single ResourceController interface however I wonder if we should reason about having a clear split between the two concept which IMHO, could make it easier to split the responsibility and to keep a clean interface so:
Creating a controller should not be required so a minimal operator could still be implemented by providing the implementation of a Reconciler. If any advanced set-up is required, then a Controller can be provided i.e: var operator = new Operator();
operator.register(new MyReconciler(), new MyController()) @Reconciler(controller = MyController.class)
class MyReconciler {
} |
@lburgazzoli I have quite a mixed feelings following this approach. But will dig deeper in the go impl since not that familiar with this part. In addition to that this segregation does are not really present in the domain language itself. I agree that it might be nice to have a separate place where we can more complex configuration. Although don't think that the current way is particularly ugly. Also denoted on that architecture diagram, this is quite fundamentally different approach, in our case its that controller seems to be more closer to But excellent point that we should start a discussion around that. |
If we were to go down that line, I think I'd rather put the |
Maybe we should just rename |
That would be ok. My main point here is that the boundaries of the |
Will update the PR with a segregated interface. |
Updated the PR, pls suggest better naming in case :) |
@csviri this is fixed, right? |
Thanks for isolating the init method :) I think decoupling the in my opinion, it will be clear that In fact, if you look at the methods that Perhaps a name like The name |
An other way would be to provide the event sources when we register the controller. So either a supplier or a list of event sources can be passed. Not sure if this is more elegant. We still need to provide access to the caches of CustomResourceEventSource inside the controller in some way then. |
Btw I'm ok to rename |
We can then rename the methods too accroding to this: |
I'm +1 on this nut don't hold any strong opinion. |
We could indeed rename |
I agree with your opinion. In my opinion, |
Well, if you take a look on the implementation it is not far either:
It's different that in our case the DefaultEventHandler does not owns/manages the watch. I think this makes sense actually to separate. And it's not accessed directly by user in our case, just would created when reconciler is registered - what is not that big deal either. So actually this looks quite close to me. It definitely meant to be a higher level concept in controller runtime, but at the end it has quite similar responsibilities as DefaultEventHandler. On the other hand it's an internal class anyways in our case, renaming would be more to our understanding also not for our users. The |
Ultimately, it doesn't matter, indeed since |
Started to working on this, two related questions:
|
hijacking a little the discussion but here we could think to rename it to |
Will do it, just we have an So we have to find a good naming to DefaultEventHandler, maybe |
For now renamed |
Back to the original topic. We have to bear in mind that the EventSources needs to accessible from the (now) Reconciler, since the caching states of the related reasources are happening in the EventSources. Given this constraints it's hard to separate these two completely (The event sources and the reconcilier), not even if we have a completely separate caching layer under the hood of the kubernetes client, since there can be non K8S dependent resources. So either we:
|
Created a separate issues where described the current changes, please take a look, we can continue the discussion there: will close this issues for now. |
Uh oh!
There was an error while loading. Please reload this page.
HI, all
I was wondering how to register eventSource in Controller, so I looked at the code.
https://github.com/java-operator-sdk/java-operator-sdk/blob/2e8f219437e53b9ca58f146a24397dbf38f0bfb8/operator-framework-core/src/main/java/io/javaoperatorsdk/operator/api/ResourceController.java#L55
Looking at this method, it looks like I can create and use my own
EventSourceManager
.However, in reality, when
operator.start()
starts,DefaultEventSourceManager
is unconditionally injected inconfiguredController.
(https://github.com/java-operator-sdk/java-operator-sdk/blob/2e8f219437e53b9ca58f146a24397dbf38f0bfb8/operator-framework-core/src/main/java/io/javaoperatorsdk/operator/processing/ConfiguredController.java#L178-L179)
And actually, the user should directly register the
EventSource
that the user wants to register with the EventSourceManager inside the init method.like this
Personally, I think this might be a bit ambiguous.
It feels like the user can directly inject and use CustomEventSourceManager .
If that's not what you intended, Rather, I think the interface below would be a little clearer.
And by calling this method in the framework, it will be able to directly register it with the event source manager.
Since
EventSourceManager
is an important component in the framework, it seems to be able to prevent it from being directly exposed to users.This is just my personal opinion.
Thank you for reading this question :)
The text was updated successfully, but these errors were encountered: