[PoC] Dynamic loading of Analysis Plugin #19809
Open
+3,404
−41
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
Overview
OpenSearch plugins are add-on components that extend the functionality of OpenSearch, providing specialized features for text analysis, security, monitoring, data transformation, and external system integration. Plugin installation typically requires restarting OpenSearch process to complete the registration adding to operational overhead.
The requirement of restarting OpenSearch process comes from the fact that plugins can only be loaded during node bootstrap while all required services/modules (e.g. pluginsService, AnalysisModule) are being initialized. We are working on a project for dynamic loading of plugins (RFC will be published soon) i.e. adding/removing plugin without restarting the OpenSearch process. As part of the project, we did a PoC for dynamic loading of Analysis Plugin. This PR consolidates all modifications and implementations from the PoC work.
Implementation Summary:
Added 3 APIs to load, register and remove plugins on demand
a. _plugins/load: Loads plugin jars from a path specified. Optionally, it registers the plugin if specified.
b. _plugins/register: Registers the plugin i.e. update the AnalysisRegistry with the components of newly loaded plugin
c. _plugins/remove: Removes plugin components from Analysis Registry
Updated PluginsService class with following:
a. Added dynamic plugin loading methods e.g. loadPluginDynamically(Path pluginPath), loadPluginByName(String pluginName, Path pluginsDirectory)
b. Updated loadPluginClass() method with class loader isolation
c. Updated loadBundle() method with lenient class loader validation
Updates in AnalysisRegistry Class:
a. Changed immutable maps to ConcurrentHashMap to update AnalysisRegistry with plugin components at runtime
b. Added dynamic plugin component management methods to update the AnalysisRegistry
c. Added cache invalidation when new plugins are added
Additionally, this PoC includes plugin management and security-related modifications.
Note: These changes were implemented to expedite PoC development and are not intended for production use. These should be replaced with dedicated plugin management APIs and refactored plugin loading mechanisms to maintain or enhance security standards.
Testing:
With above mentioned changes were able to add multiple analysis plugin at runtime. Following are the test execution details of adding/removing 'analysis-icu' plugin with single node cluster at runtime:
Related Issues
Placeholder RFC link