Skip to content

feat: allow reconcilers to override their own configuration #2779

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

metacosm
Copy link
Collaborator

Signed-off-by: Chris Laprun claprun@redhat.com

@metacosm metacosm self-assigned this Apr 30, 2025
@metacosm metacosm requested review from csviri and xstefank April 30, 2025 14:42
Copy link
Collaborator

@csviri csviri left a comment

Choose a reason for hiding this comment

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

What is the use case for this change?

Would be good to document it at least as Javadoc on the interface

@metacosm
Copy link
Collaborator Author

metacosm commented May 3, 2025

What is the use case for this change?

This allows for Reconciler implementations to customize their configuration based on runtime information before being registered in situations where programmatic configuration via manually created ControllerConfigurationOverrider might not be easy or straightforward, like the Quarkus extension (and could potentially simplify the Spring Boot starter as well).

metacosm added 2 commits May 3, 2025 20:15
Signed-off-by: Chris Laprun <claprun@redhat.com>
Signed-off-by: Chris Laprun <claprun@redhat.com>
@metacosm metacosm force-pushed the configure-controller branch from dafb814 to fa23191 Compare May 3, 2025 18:17
@goldmann
Copy link

goldmann commented May 5, 2025

I like this approach. It will definitely make my life easier where I have many label selectors that I'm adjusting based on two sources: a Map in the code and env variables set at deployment time. And this multiplied by a number of controllers.

Copy link
Collaborator

@xstefank xstefank left a comment

Choose a reason for hiding this comment

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

The only thing I don't understand is why it's not applied the first time getConfigurationFor is called.

@csviri
Copy link
Collaborator

csviri commented May 5, 2025

What is the use case for this change?

This allows for Reconciler implementations to customize their configuration based on runtime information before being registered in situations where programmatic configuration via manually created ControllerConfigurationOverrider might not be easy or straightforward, like the Quarkus extension (and could potentially simplify the Spring Boot starter as well).

I see thank you, makes sense, just some remarks:

Just for the record: In general in v5 we aimed to remove interface implementation for reconciler since are not easy to discover. However since this is mainly intended for the extension (quarkus/SB) I think it is better to do this way as it is then having it as a default method on reconciler interface.

What however, might be considered as an alternative ( and let me know this if this is also feasible on Quarkus side), I'm quite sure this would work in SB, but can prepare a prototype; is this:

To not bake this mechanism into the core, rather have this interface in the extensions only, and provide it as a bean:

@Singleton
@ForController(MyController.class)
@ForController(MyOtherController.class)
public class MyConfigOverrode implements ConfigurableReconciler {

@Inject 
Object anyBeanOrRuntimeValue

void updateConfigurationFrom(ControllerConfigurationOverrider configOverrider) {
 // my code to use override, possibly using runtime injected beans.
}

}

Then is bean instance could be easily used with the current API when the reconciler is registered in the background.

Note the @ForController(MyController.class) part. This could be used to identify the controller(s), thus possibly more controllers that share some common values, like label selectors.

Can expand on this later, hope it is clear how I mean it. Pls let me know what do you think. The pros is that we don't have to introduce an other construct to the core, also might be a more flexible approach for the users (maybe with a more modern API? ). On the other hand the config is not tightly coupled with the reconciler (which might be a good and also a bad thing).

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.

4 participants