Skip to content

[Discuss] Consider changing how classloading works for extensible and extending plugins #19440

@cwperks

Description

@cwperks

tldr;

Plugins should control their deps and not have to wonder about whether plugins they extend provide a dep at runtime

Longer version:

ExtensiblePlugin is an interesting sort of extension point for OpenSearch. It allows us to define additional ways of extending core functionality, but writing another extension point outside of the core. Two such common use-cases are lang-painless and the opensearch-job-scheduler. With ExtensiblePlugins, plugins define relationships to one another.

For instance, the reporting plugin extends the opensearch-job-scheduler in order to get job scheduling functionality to run reports on a schedule.

There is one not so obvious thing about these plugins relations and that is how their classloaders relate.

When the reporting plugin extends the job scheduler, a side-effect is that job-scheduler's dependencies are available to the reporting plugin at runtime. However, the same dependencies are not available to reporting at compile time.

As a result, you find extending plugins setting compileOnly declarations on dependencies that they share with their extended plugin.

This causes some headache to plugin developers when extending other plugins because they are at the whim of the extensible plugin deciding to add dependencies that they also rely upon.

I'm opening this issue to discuss if we can change how classloading works for extensible and extending plugins.

In particular, I'd like to explore removing extendedLoaders from here: https://github.com/opensearch-project/OpenSearch/blob/main/server/src/main/java/org/opensearch/plugins/PluginsService.java#L789

Related component

No response

To Reproduce

Prevent issues such as opensearch-project/ml-commons#4202

Expected behavior

No jar hell if extensible and extending plugin have the same implementation level dep.

Additional Details

Extensible plugins have been being used much more than from the earlier days of OpenSearch.

Metadata

Metadata

Assignees

No one assigned

    Labels

    BuildBuild Tasks/Gradle Plugin, groovy scripts, build tools, Javadoc enforcement.PluginsbugSomething isn't workinguntriaged

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions