-
Notifications
You must be signed in to change notification settings - Fork 5.4k
Allow conditional loading of plugins #24965
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
base: master
Are you sure you want to change the base?
Allow conditional loading of plugins #24965
Conversation
dbf3e2f
to
2fc78ff
Compare
Logs from running PrestoServer locally:
|
The general model for all plugins has been that you should be able to load plugins without having any side effects if they aren't enabled. Also, as far as cluster configuration, it's inconvenient to have to disable the plugin in addition to setting use side car to false. instead, i think it would be better for the NativeSessionpropertyProviders to have different names (currently the coordinator based one and the sidecar based one are both called native-worker), and loadSystemSessionProperty providers only loads the providers that are relevant for the configuration (similar to how AccessControlManager.loadSystemAccessControl(), but with a different/slightly more complicated combination of configs. |
9b2570c
to
a019db9
Compare
@rschlussel Thanks for the response. |
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 seems like a fine option
- is it possible to add a test that everything starts up properly now if the plugin is loaded but the config is not enabled?
- For some sidecar features it might be nice to have an additional flag that enables them (e.g. you want to disable sidecar constant folding at first, but still use the function registry). Would this kind of approach still work if something needs two configs to be enabled?
For 1, I will try to come up with a test case.
I cannot think of a reason why we should not be able to have additional configs, we even have individual load methods for the sidecar functionalities like Though, there's a possibility using part of the |
a019db9
to
242315d
Compare
@rschlussel
For supporting multiple configs, added a new annotation which handles that, still could not find out how to unit test this though. Maybe we can let this change pass, create an issue and handle the unit test at a later time? |
We only need the annotation for |
5fb0555
to
d4d22da
Compare
|
||
@Retention(RetentionPolicy.RUNTIME) | ||
@Target(ElementType.TYPE) | ||
public @interface ConditionalOnConfigs |
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.
Why do we need this variant?
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.
It handles a list of @ConditionalOnConfig
.
The idea is to have the ability to have additional config flags on the sidecar functionalities to conditionally load individual functionalities.
As in let's say on the NativeFunctionNamespaceManager
, we have two @ConditionalOnConfig
configs coordinator-sidecar-enabled
and load-function-registry
.
@@ -420,8 +427,11 @@ public void loadTypeManager(String typeManagerName) | |||
|
|||
public void loadTypeManagers() | |||
{ | |||
for (String typeManagerName : typeManagerFactories.keySet()) { | |||
loadTypeManager(typeManagerName); | |||
Map<String, String> configMap = ImmutableMap.of("coordinator-sidecar-enabled", String.valueOf(serverConfig.isCoordinatorSidecarEnabled())); |
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.
Do we have a static constant anywhere that we can reference rather than repeating this string?
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.
No, but can make one.
@@ -150,8 +157,13 @@ public void loadSessionPropertyProvider(String sessionPropertyProviderName, Opti | |||
|
|||
public void loadSessionPropertyProviders() | |||
{ | |||
for (String sessionPropertyProviderName : workerSessionPropertyProviderFactories.keySet()) { | |||
loadSessionPropertyProvider(sessionPropertyProviderName, functionAndTypeManager, nodeManager); | |||
Map<String, String> configMap = ImmutableMap.of("coordinator-sidecar-enabled", String.valueOf(serverConfig.isCoordinatorSidecarEnabled())); |
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.
I'm wondering if there's a better way to load the map of properties so that this code is more generic. It seems tailored specifically for the sidecar. If any other plugin needed to make use of ConditionalOnConfig, the property would need to get added here which is not ideal.
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.
It seems like the best option.
We could have the factories provide the required properties, but we would need to push the config values down to the factories, which doesn't seem to be possible.
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.
It might be possible to have just one generic configMap
with the properties, because if the properties aren't present in the provider class we just assume it to be true
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.
@ZacBlanco
What if we get a list of all the config properties using injector.getInstance(ConfigurationFactory.class).getProperties()
; in PrestoServer.java
and pass it down to PluginManager.java
.
While loading the plugin, check the annotations to see if all the properties are satisfied, if yes load it.
Alternatively , if we don't want to use annotations, we can add a getRequiredConfigs()
method in both Plugin.java
and CoordinatorPlugin.java
which would return a map of required properties to load this plugin.
Any plugin can override this method, returns its own set of configs, which can be validated before loading the plugin, making this validation generic for all plugins.
What do you think of this approach?
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.
However, for the second approach, loading individual components of plugins like NativeSidecarPlugin
might be tricky. For that use case, the annotations approach would be easier to handle.
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.
I think the second approach should be okay. If you have the sidecar configured, as long as it's possible to set the particular component (e.g. constant folding thing) to the non-sidecar version without issue, it should be okay to have it loaded as long as there's no side effect. I think just making sure different implementations of the component (e.g. java builtin vs. sidecar) are registered different names should generally be enough.
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 to control the loading of functionalities of the sidecar? Like loading the function registry without the constant folding thing.
For eg: If you do not want to use NativeTypeManager
and you load the NativeSidecarPlugin
with coordinator-sidecar-enabled
true, we load the NativeTypeManager
which is the default type manager now, in this case, we want to skip loading the native type manager itself.
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.
Also, to clarify we are talking about the getRequiredConfigs()
approach right?
That approach has the config properties defined at the Plugin
level not at the individual components level.
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.
i think it's okay if it's loaded as long as it's not configured as the one to use and loading it in itself won't break anything.
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.
and yes getRequiredConfigs() approach.
@pdabre12 @ZacBlanco @rschlussel Folks will be really helpful if we can merge this one. Without this change, we can't include the plugin in build and can't test out any of the good changes coming with it. CC: @kewang1024 |
d4d22da
to
3fb82c6
Compare
3fb82c6
to
521129b
Compare
521129b
to
4dbb12e
Compare
Description
Adds logic for conditional loading of the
presto-native-sidecar-plugin
plugin module.Motivation and Context
Solves part of #24964
Impact
Users would be able to include the
presto-native-sidecar-plugin
plugin in the build, and not load the functionalities ifcoordinator-sidecar-enabled
is set to false.Test Plan
Unit tests
Contributor checklist
Release Notes