Skip to content

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

Merged
merged 7 commits into from
Jan 20, 2021

Conversation

metacosm
Copy link
Collaborator

@metacosm metacosm commented Jan 14, 2021

Fixes #302

@@ -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));
Copy link
Contributor

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.

Copy link
Collaborator Author

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.

Copy link
Contributor

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.

Copy link
Collaborator Author

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.

Copy link
Contributor

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

Copy link
Contributor

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?

Copy link
Collaborator Author

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.

Copy link
Contributor

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,...

Copy link
Collaborator Author

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! 😄

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is now done.

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).
@metacosm metacosm marked this pull request as ready for review January 20, 2021 11:51
@wtrocki
Copy link

wtrocki commented Jan 20, 2021

+100 to get this merged. I have built this locally and tried it.

@adam-sandor
Copy link
Collaborator

Thanks @wtrocki ! let's merge it then

@adam-sandor adam-sandor merged commit be912b7 into master Jan 20, 2021
@metacosm metacosm deleted the clean-register branch January 22, 2021 23:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Clean up handling of target namespaces
4 participants