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

[BUG] Unable to install lang-painless module when testDistribution is set to INTEG_TEST for k-NN #1676

Closed
jmazanec15 opened this issue Dec 1, 2021 · 25 comments

Comments

@jmazanec15
Copy link
Member

What is the bug?
For k-NN, I am trying to run integ tests on Mac. To do this, I first switched testDistribution from ARCHIVE to INTEG_TEST. Otherwise, it cannot find the OpenSearch artifact:

Execution failed for task ':run'.
> Could not resolve all files for configuration ':opensearch_distro_extracted_testclusters--integTest-0-1.3.0-SNAPSHOT-'.
   > Could not resolve opensearch-distribution-snapshot:opensearch:1.3.0-SNAPSHOT.
     Required by:
         project :
      > Could not resolve opensearch-distribution-snapshot:opensearch:1.3.0-SNAPSHOT.
         > Could not get resource 'https://artifacts.opensearch.org/snapshots/core/opensearch/1.3.0-SNAPSHOT/opensearch-min-1.3.0-SNAPSHOT-darwin-x64-latest.tar.gz'.
            > Could not HEAD 'https://artifacts.opensearch.org/snapshots/core/opensearch/1.3.0-SNAPSHOT/opensearch-min-1.3.0-SNAPSHOT-darwin-x64-latest.tar.gz'. Received status code 403 from server: Forbidden

After making the above switch, it is able to download, but fails with the following error (k-NN has a dependency on lang-painless):

| Exception in thread "main" java.lang.IllegalArgumentException: Missing plugin [lang-painless], dependency of [opensearch-knn]
|       at org.opensearch.plugins.PluginsService.addSortedBundle(PluginsService.java:512)
|       at org.opensearch.plugins.PluginsService.sortBundles(PluginsService.java:480)
|       at org.opensearch.plugins.InstallPluginCommand.jarHellCheck(InstallPluginCommand.java:839)
|       at org.opensearch.plugins.InstallPluginCommand.loadPluginInfo(InstallPluginCommand.java:813)
|       at org.opensearch.plugins.InstallPluginCommand.installPlugin(InstallPluginCommand.java:858)
|       at org.opensearch.plugins.InstallPluginCommand.execute(InstallPluginCommand.java:263)
|       at org.opensearch.plugins.InstallPluginCommand.execute(InstallPluginCommand.java:237)
|       at org.opensearch.cli.EnvironmentAwareCommand.execute(EnvironmentAwareCommand.java:100)
|       at org.opensearch.cli.Command.mainWithoutErrorHandling(Command.java:138)
|       at org.opensearch.cli.MultiCommand.execute(MultiCommand.java:104)
|       at org.opensearch.cli.Command.mainWithoutErrorHandling(Command.java:138)
|       at org.opensearch.cli.Command.main(Command.java:101)
|       at org.opensearch.plugins.PluginCli.main(PluginCli.java:60)

This is because the modules do not come with the INTEG_TEST distribution.

So, I create the lang painless module from source and placed it in test resources. Then, I add it as a plugin. However, this then fails with this error:

| ERROR: plugin 'lang-painless' cannot be installed as a plugin, it is a system module

So, I switch this line from plugin to module. However, this then produces the missing plugin error again:

| Exception in thread "main" java.lang.IllegalArgumentException: Missing plugin [lang-painless], dependency of [opensearch-knn]
|       at org.opensearch.plugins.PluginsService.addSortedBundle(PluginsService.java:512)
|       at org.opensearch.plugins.PluginsService.sortBundles(PluginsService.java:480)
|       at org.opensearch.plugins.InstallPluginCommand.jarHellCheck(InstallPluginCommand.java:839)
|       at org.opensearch.plugins.InstallPluginCommand.loadPluginInfo(InstallPluginCommand.java:813)
|       at org.opensearch.plugins.InstallPluginCommand.installPlugin(InstallPluginCommand.java:858)
|       at org.opensearch.plugins.InstallPluginCommand.execute(InstallPluginCommand.java:263)
|       at org.opensearch.plugins.InstallPluginCommand.execute(InstallPluginCommand.java:237)
|       at org.opensearch.cli.EnvironmentAwareCommand.execute(EnvironmentAwareCommand.java:100)
|       at org.opensearch.cli.Command.mainWithoutErrorHandling(Command.java:138)
|       at org.opensearch.cli.MultiCommand.execute(MultiCommand.java:104)
|       at org.opensearch.cli.Command.mainWithoutErrorHandling(Command.java:138)
|       at org.opensearch.cli.Command.main(Command.java:101)
|       at org.opensearch.plugins.PluginCli.main(PluginCli.java:60)

I was wondering if there is any way to prevent gradle from attempting to install an extended plugin as a plugin when it is a module.

How can one reproduce the bug?
Steps to reproduce the behavior:

  1. Clone the repo
git clone https://github.com/jmazanec15/k-NN-1.git
cd k-NN-1 
git checkout build-on-mac
  1. Install dependencies
brew install openblas
  1. Run build
./gradlew build

What is the expected behavior?
Expect to be able to add lang-painless as a module.

What is your host/environment?

  • OS: Mac Big Sur
  • Version 1.3
  • Plugins k-NN, lang-painless
@dblock
Copy link
Member

dblock commented Dec 7, 2021

Should we move this issue into OpenSearch repo? That’s where we’d be fixing it, right?

@saratvemulapalli saratvemulapalli transferred this issue from opensearch-project/opensearch-plugins Dec 8, 2021
@saratvemulapalli
Copy link
Member

@jmazanec15 Modules are only installed for INTEG_TEST test distribution.
Ref: https://github.com/opensearch-project/OpenSearch/blob/main/buildSrc/src/main/java/org/opensearch/gradle/testclusters/OpenSearchNode.java#L725
Manually installing a module will also fail because its not a plugin.

The rootcause of the problem is 1.3.0-SNAPSHOT opensearch min artifact is not available for darwin.
https://artifacts.opensearch.org/snapshots/core/opensearch/1.3.0-SNAPSHOT/opensearch-min-1.3.0-SNAPSHOT-darwin-x64-latest.tar.gz
Here is the issue: opensearch-project/opensearch-build#38 which is tracking for 1.3 release.

So unless that is resolved running integration tests on darwin would not work.
The alternative solution is to run integration tests while spinning up an external cluster: opensearch-project/opensearch-plugins#103

That said, for the last part of the question:
I was wondering if there is any way to prevent gradle from attempting to install an extended plugin as a plugin when it is a module.
The ARCHIVE test distribution was not intended was these reasons. You should continue to use INTEG_TEST distribution to have modules installed by default.

@saratvemulapalli
Copy link
Member

Closing this. Feel free to reopen if the comment does not help.

@jmazanec15
Copy link
Member Author

@saratvemulapalli Not sure I have the ability to reopen, but wanted to continue discussion.

I tried switching to INTEG_TEST, but this does not come with modules other than transport-netty.

I was thinking about installing the "lang-painless" in the following way:

  1. Adding a dependency on it in my build.gradle.
configurations {
    painless
}

dependencies {
    ...
    painless "org.opensearch.plugin:lang-painless:${opensearch_version}"
}

  1. Zipping up the files pulled from the dependency as a gradle task
task prepareLangPainlessZip(type: Zip) {
    from configurations.painless.allArtifacts.files
    from configurations.painless
    destinationDirectory = layout.buildDirectory.dir("jack")
    archiveFileName = "lang-painless.zip"
}
  1. Adding the zip as a module in the cluster setup:
testClusters.integTest {
    testDistribution = "INTEG_TEST"
    module(provider(new Callable<RegularFile>(){
        @Override
        RegularFile call() throws Exception {
            return new RegularFile() {
                @Override
                File getAsFile() {
                    return fileTree("build/jack").getSingleFile()
                }
            }
        }
    }))
    ...
}

However, I get the following error:

| Exception in thread "main" java.lang.IllegalStateException: Could not load plugin descriptor for module directory [lang-painless]
|       at org.opensearch.plugins.PluginsService.readPluginBundle(PluginsService.java:452)
|       at org.opensearch.plugins.PluginsService.findBundles(PluginsService.java:437)
|       at org.opensearch.plugins.PluginsService.getModuleBundles(PluginsService.java:425)
|       at org.opensearch.plugins.InstallPluginCommand.jarHellCheck(InstallPluginCommand.java:849)
|       at org.opensearch.plugins.InstallPluginCommand.loadPluginInfo(InstallPluginCommand.java:825)
|       at org.opensearch.plugins.InstallPluginCommand.installPlugin(InstallPluginCommand.java:870)
|       at org.opensearch.plugins.InstallPluginCommand.execute(InstallPluginCommand.java:275)
|       at org.opensearch.plugins.InstallPluginCommand.execute(InstallPluginCommand.java:249)
|       at org.opensearch.cli.EnvironmentAwareCommand.execute(EnvironmentAwareCommand.java:100)
|       at org.opensearch.cli.Command.mainWithoutErrorHandling(Command.java:138)
|       at org.opensearch.cli.MultiCommand.execute(MultiCommand.java:104)
|       at org.opensearch.cli.Command.mainWithoutErrorHandling(Command.java:138)
|       at org.opensearch.cli.Command.main(Command.java:101)
|       at org.opensearch.plugins.PluginCli.main(PluginCli.java:60)
| Caused by: java.nio.file.NoSuchFileException: .../k-NN-1/build/testclusters/integTest-0/distro/2.0.0-INTEG_TEST/modules/lang-painless/plugin-descriptor.properties
|       at java.base/sun.nio.fs.UnixException.translateToIOException(UnixException.java:92)
|       at java.base/sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:111)
|       at java.base/sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:116)
|       at java.base/sun.nio.fs.UnixFileSystemProvider.newByteChannel(UnixFileSystemProvider.java:219)
|       at java.base/java.nio.file.Files.newByteChannel(Files.java:375)
|       at java.base/java.nio.file.Files.newByteChannel(Files.java:426)
|       at java.base/java.nio.file.spi.FileSystemProvider.newInputStream(FileSystemProvider.java:420)
|       at java.base/java.nio.file.Files.newInputStream(Files.java:160)
|       at org.opensearch.plugins.PluginInfo.readFromProperties(PluginInfo.java:199)
|       at org.opensearch.plugins.PluginsService.readPluginBundle(PluginsService.java:449)

I have a couple questions:

  1. Why plugins in https://aws.oss.sonatype.org/content/repositories/snapshots/org/opensearch/plugin/ do not contain the plugin descriptors?
  2. Why is module call trying to use plugin cli?
  3. Is there a better way to go about doing this?

Related issue: opensearch-project/opensearch-build#1750 (comment)

@saratvemulapalli
Copy link
Member

I can re-open the issue.

@jmazanec15
Copy link
Member Author

@ryanbogan @saratvemulapalli @dblock @prudhvigodithi Wanted to follow up on this. Right now, we (k-NN) cannot run integration tests on Mac because we are not able to get the lang-painless zip artifact for the INTEG TEST distribution. I believe that Alerting has the same issue.

With opensearch-project/opensearch-build#716 and opensearch.pluginzip, will we be able to add a dependency to pull core plugin artifacts from Maven so that we can install painless on the testcluster?

@dblock
Copy link
Member

dblock commented May 18, 2022

@prudhvigodithi should be able to answer ^

@prudhvigodithi
Copy link
Member

Hey @jmazanec15 opensearch.pluginzip, this will publish the generated distribution plugin zip's to maven repo, is lang-painless zip part of any plugin bundle task? If so yes this opensearch.pluginzip can be used to publish to maven repo with right maven coordinates.

@jmazanec15
Copy link
Member Author

@prudhvigodithi I am not sure if its a part of any plugin bundle task. It is a core module. Is there a plan to publish all core plugin/module zips so that they can be consumed?

@jmazanec15
Copy link
Member Author

It seems like there are several other plugins that might have this issue (i.e. cant bring up cluster on mac):

  1. https://github.com/opensearch-project/anomaly-detection/blob/main/build.gradle#L616
  2. https://github.com/opensearch-project/alerting/blob/main/alerting/build.gradle#L82
  3. https://github.com/opensearch-project/asynchronous-search/blob/main/build.gradle#L117

I am wondering if, given that modules are meant to be shipped with OpenSearch, it makes sense to have a testDistribution that includes modules and works on mac.

Im not sure if this means adding support for it through the ARCHIVE distribution, or adding another distribution similar to INTEG_TEST.

What do you think? @dblock @saratvemulapalli @prudhvigodithi @ryanbogan .

@amitgalitz
Copy link
Member

It seems like there are several other plugins that might have this issue (i.e. cant bring up cluster on mac):

  1. https://github.com/opensearch-project/anomaly-detection/blob/main/build.gradle#L616
  2. https://github.com/opensearch-project/alerting/blob/main/alerting/build.gradle#L82
  3. https://github.com/opensearch-project/asynchronous-search/blob/main/build.gradle#L117

I am wondering if, given that modules are meant to be shipped with OpenSearch, it makes sense to have a testDistribution that includes modules and works on mac.

Im not sure if this means adding support for it through the ARCHIVE distribution, or adding another distribution similar to INTEG_TEST.

What do you think? @dblock @saratvemulapalli @prudhvigodithi @ryanbogan .

+1 on this issue, Anomaly Detection is experiencing the exact same bug.

@saratvemulapalli
Copy link
Member

@amitgalitz @jmazanec15 I see it as a workaround to help install default modules for a test distribution(INTEG_TEST/ new distribution) to run tests on MacOS.
The ARCHIVE test distribution already is bundled with all default modules (including lang-painless) but its not available on MacOS yet[1].
cc: @bbarani

My thoughts, I would rather have it supported the right way rather than putting in a work around.
That said, if this is impacting your productivity we can look at alternative options.

[1] opensearch-project/opensearch-build#38

@jmazanec15
Copy link
Member Author

That said, if this is impacting your productivity we can look at alternative options.

In general, it creates a lot of extra effort for someone to rampup on the project. They have to figure out a system that will sync mac dev environment with linux. Also, makes running debuggers more difficult. Overall, makes the bar to contribute higher.

opensearch-project/opensearch-build#38 seems to be focused on supporting the bundle as a whole on Mac. I am wondering if as a first step, we could just enable it for OpenSearch and its modules to unblock development. Specifically, focus on making ARCHIVE work on Mac as opposed to waiting for Mac bundle to be ready and supported.

@saratvemulapalli
Copy link
Member

In general, it creates a lot of extra effort for someone to rampup on the project. They have to figure out a system that will sync mac dev environment with linux. Also, makes running debuggers more difficult. Overall, makes the bar to contribute higher.

Absolutely, I feel the pain as well :).

opensearch-project/opensearch-build#38 seems to be focused on supporting the bundle as a whole on Mac. I am wondering if as a first step, we could just enable it for OpenSearch and its modules to unblock development. Specifically, focus on making ARCHIVE work on Mac as opposed to waiting for Mac bundle to be ready and supported.

Yeah that would be a nice intermediate step which unblocks this, I love this idea.
Which is btw already available from OpenSearch, its just that opensearch-build has to publish the artifact.
Is this something your team could consider ? @bbarani @peterzhuamazon

@bbarani
Copy link
Member

bbarani commented Jun 17, 2022

@saratvemulapalli Can you please clarify the artifact that you are referring in the above comment? Are you referring to opensearch-min artifact?

@saratvemulapalli
Copy link
Member

@saratvemulapalli Can you please clarify the artifact that you are referring in the above comment? Are you referring to opensearch-min artifact?

Correct, opensearch-min artifact for MacOS (darwin).

@dblock
Copy link
Member

dblock commented Jun 17, 2022

Does a cross-platform build for MacOS work on MacOS? If so we can probably add to the existing Jenkinsfile a "mac" build that's good enough?

@prudhvigodithi
Copy link
Member

prudhvigodithi commented Jun 18, 2022

Does a cross-platform build for MacOS work on MacOS? If so we can probably add to the existing Jenkinsfile a "mac" build that's good enough?

@dblock, or we can just run the distribution build on macOS ec2 jenkins agent, then the logic PLATFORM uname -s will be inferred as Darwin
https://aws.amazon.com/ec2/instance-types/mac/
@bbarani @peterzhuamazon

@bbarani
Copy link
Member

bbarani commented Jun 20, 2022

We are currently exploring this option. We will update this thread soon with our findings.

CC: @prudhvigodithi @saratvemulapalli @jmazanec15 @dblock

@prudhvigodithi
Copy link
Member

Hey @jmazanec15, can you please test with opensearch-min-2.0.1-darwin-x64.tar.gz
https://ci.opensearch.org/ci/dbc/Playground/distribution-build-opensearch-pgodithi/2.0.1/0/darwin/x64/builds/opensearch/dist/opensearch-min-2.0.1-darwin-x64.tar.gz
NOTE: This is not a final darwin published artifact, this is to just test the OpenSearch min darwin format.

@jmazanec15
Copy link
Member Author

jmazanec15 commented Jun 20, 2022

Yes it works!

./bin/opensearch-plugin install file:/Users/jmazane/opensearch-knn-2.0.1.0.zip
warning: ignoring JAVA_TOOL_OPTIONS=-Dlog4j2.formatMsgNoLookups=true
...
[=================================================] 100%
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@     WARNING: plugin requires additional permissions     @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
* java.lang.RuntimePermission loadLibrary.opensearchknn_faiss
* java.lang.RuntimePermission loadLibrary.opensearchknn_nmslib
* java.net.SocketPermission * connect,resolve
See http://docs.oracle.com/javase/8/docs/technotes/guides/security/permissions.html
for descriptions of what these permissions allow and the associated risks.

Continue with installation? [y/N]y
-> Installed opensearch-knn with folder name opensearch-knn

./bin/opensearch
...
[2022-06-20T16:15:10,817][INFO ][o.o.p.PluginsService     ]  loaded plugin [opensearch-knn]
...

curl localhost:9200/_cat/plugins
xxxxx opensearch-knn 2.0.1.0

Just to be sure, this will get published to something like

'https://artifacts.opensearch.org/snapshots/core/opensearch/2.0.1-SNAPSHOT/opensearch-min-2.0.1-SNAPSHOT-darwin-x64-latest.tar.gz'

correct?

@navneet1v
Copy link
Contributor

Similar issue but happening for all the OS versions with mavenLocalPublish. Can someone please take a look at this too?

@prudhvigodithi
Copy link
Member

prudhvigodithi commented Jun 21, 2022

Just to be sure, this will get published to something like

'https://artifacts.opensearch.org/snapshots/core/opensearch/2.0.1-SNAPSHOT/opensearch-min-2.0.1-SNAPSHOT-darwin-x6

Hey @jmazanec15 will post an update regarding the darwin final download URL.
Thank you

@saratvemulapalli
Copy link
Member

Closing this. Thanks for all the work @prudhvigodithi.

@navneet1v
Copy link
Contributor

@prudhvigodithi Thanks for the work. This was really a blocker for the development on mac.

@prudhvigodithi prudhvigodithi self-assigned this Oct 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

10 participants