Skip to content
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

Add dependent plugins validation during plugin load #1119

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

junqiu-lei
Copy link
Member

@junqiu-lei junqiu-lei commented Jan 17, 2025

Description

Add dependent plugins validation during neural search plugin load stage.

Related Issues

Closes #480

Check List

  • New functionality includes testing.
  • New functionality has been documented.
  • API changes companion pull request created.
  • Commits are signed per the DCO using --signoff.
  • Public documentation issue/PR created.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.

@junqiu-lei junqiu-lei added the backport 2.x Label will add auto workflow to backport PR to 2.x branch label Jan 17, 2025
@junqiu-lei junqiu-lei self-assigned this Jan 17, 2025
heemin32
heemin32 previously approved these changes Jan 17, 2025
@heemin32
Copy link
Collaborator

heemin32 commented Jan 17, 2025

Thanks for the PR.

Could you confirm it will fail in both cases?

  1. Attempting to install the neural plugin without having the ml-common plugin already installed.
  2. Installing both the ml-common and neural plugins, then removing the ml-common plugin and restarting the cluster.

Because we added knn and ml common code as dependency through gradle, this Class.forName(org.opensearch.knn.plugin.KNNPlugin) might fail to check the actual installation of the plugin in the OpenSearch cluster.

Comment on lines +92 to +95
"opensearch-knn",
"org.opensearch.knn.plugin.KNNPlugin",
"opensearch-ml-commons",
"org.opensearch.ml.client.MachineLearningClient"
Copy link
Member

Choose a reason for hiding this comment

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

I do not have much context. Can you please explain why org.opensearch.knn.plugin.KNNPlugin and org.opensearch.ml.client.MachineLearningClient still needs check even if both opensearch-knn and opensearch-ml-commons are available

Copy link
Collaborator

@heemin32 heemin32 Jan 17, 2025

Choose a reason for hiding this comment

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

opensearch-knn is just a plugin name we are using in a log and org.opensearch.knn.plugin.KNNPlugin is the actual class that we are validating its existence.

I think this code might look confusing. Can we change to something like this?

public enum DependentPlugin {
  private String klass;

  ML_COMMON("org.opensearch.ml.client.MachineLearningClient"),
  KNN("org.opensearch.knn.plugin.KNNPlugin");

  DependentPlugin(final String klass) {
    this.klass = klass;
  }

  public void validateAvailability() {
    try {
               Class.forName(klass);
               log.info("Plugin [{}] is installed", this.name());
     } catch (ClassNotFoundException e) {
                throw new IllegalStateException("Neural Search plugin requires the " + this.name() + " plugin to be installed", e);
     }
  }
}

@heemin32 heemin32 dismissed their stale review January 17, 2025 16:09

Few suggestions were added

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport 2.x Label will add auto workflow to backport PR to 2.x branch enhancement help wanted Extra attention is needed Maintenance Add support for new versions of OpenSearch/Dashboards from upstream
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Check if ml-commons plugin is installed in the Cluster
3 participants