-
Notifications
You must be signed in to change notification settings - Fork 220
Simplify controller registration and unify controller configuration #303
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
@@ -24,7 +24,7 @@ public static void main(String[] args) throws IOException { | |||
Config config = new ConfigBuilder().withNamespace(null).build(); | |||
KubernetesClient client = new DefaultKubernetesClient(config); | |||
Operator operator = new Operator(client, DefaultConfigurationService.instance()); | |||
operator.registerControllerForAllNamespaces(new SchemaController(client)); | |||
operator.register(new SchemaController(client)); |
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.
How does user can configure the namespaces in runtime then?
Note that whatever is going to be implemented should work for pure-java operators as well.
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.
This is done by using namespaces = ControllerConfiguration.WATCH_ALL_NAMESPACES_MARKER
on the Controller
annotation.
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.
That’s not changale in runtime,
In pure java operators it still should be possible for user to get the namespaces some how and respct them in registration.
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.
This should be overridden via externalized configuration.
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.
Not sure what external configuration for pure-java applications mean!
Isn’t that too opinionated? Also do we have this possibility already?
I’m asking because I’m using the removed methods to configure my controllers already and there may be other users who use them, so we need to offer a reasonable alternative before removing them
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.
User 1 wants to run operatopr OP1 just for namespace ns1
User 2 wants to run operatopr OP1 for namespaces ns1 and ns2
User 3 wants to run operatopr OP1 for all the namespaces
The operator is in pure-java and is deciding which namespaces are in the interest of the operator via command-line arguments.
So it either calls registerControllerForAllNamespaces
method if ALL is sent as argument method or call registerController
with the list of given namespaces.
Now the question is how the same thing can be achieved after removing these methods?
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.
That makes sense. How about a register(controller, overrideConfiguration)
method? It's probably more complex to implement than keeping the separate methods but the issue is that we should always go through the configuration to register controllers because that also has impacts on the event sources and it's not done consistently everywhere.
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.
Yep it makes sense to have a configuration class with convenient to use method to let the user change the stuff that are useful to be configured in runtime like: retry, namespaces, cluster scoped,...
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.
Ok, I'll get on that then! 😄
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.
This is now done.
42f5efd
to
fed51b0
Compare
dad1b33
to
5921a6c
Compare
The intent here is that controllers should be registered according to their configuration. This will become even more relevant when externalized configuration is in place (see #237). This also means using ControllerConfiguration.WATCH_ALL_NAMESPACES_MARKER in the namespaces field of the Controller annotation where appropriate since that's what ControllerConfiguration uses to determine if a controller should watch all namespaces. This still needs to be unified across the code base (see #302).
5921a6c
to
456ea3c
Compare
+100 to get this merged. I have built this locally and tried it. |
Thanks @wtrocki ! let's merge it then |
Fixes #302