opensearch-project / OpenSearch

🔎 Open source distributed and RESTful search engine.
https://opensearch.org/docs/latest/opensearch/index/
Apache License 2.0
9.88k stars 1.84k forks source link

[BUG] opensearch-cli is borked #10324

Open ajacques opened 1 year ago

ajacques commented 1 year ago

Describe the bug The opensearch-cli command does not work and gives an error message:

bin/opensearch-cli -h
Error: Could not find or load main class 
Caused by: java.lang.ClassNotFoundException: 

The script appears to be referencing an environment variable OPENSEARCH_MAIN_CLASS, however this env variable is not set anywhere in this script, thus it can't execute the Java Class

To Reproduce Steps to reproduce the behavior:

  1. Go to https://opensearch.org/docs/latest/tools/cli/
  2. Download the Linux version and extract the tar.gz
  3. cd opensearch-2.10.0/
  4. bin/opensearch-cli
  5. See error

Expected behavior I would expect to be able to run the CLI command following the docs that are listed on the official docs

Plugins N/A

Screenshots If applicable, add screenshots to help explain your problem.

Host/Environment (please complete the following information):

Additional context Add any other context about the problem here.

dblock commented 1 year ago

Care to dig into it @ajacques? If this is broken I'd love to know when it broke, and I am going to guess it was a long time ago (in which case is nobody using the tool?). We'll either need to fix it with tests, or remove it.

ajacques commented 1 year ago

It seems to have broken in this commit 95795c8935b2c421ae47dcbb0e2300ac2905ec5a. It appears that the other CLI shell scripts would call into this shell script and pass the main class name, but the docs still refer to opensearch-cli. These commands were added into the docs as part of an initial commit https://github.com/opensearch-project/documentation-website/commit/2729ce3ccbd73f77eb1b21ee1b8732461c3828a8 and it's not clear where they came from before.

In theory there's an opensearch-cli curl command which seems like it would be helpful to me right now, but I've searched the OpenSearch code-base and haven't found any sub-classes of the Command that appear to match any of these commands as referenced in the docs.

This docs page appears to have been written around the release of OpenSearch 1.0.0, so I even pulled that commit and searched that code and didn't find any references to "profile" or "curl" that fit within the context of a CLI command. I suspect this entire docs page is not meaningful. The opensearch-cli profile should be easier to find since it should inherit from MultiCommand, but the results don't show a profile either.

Given this, it appears that the docs are wrong and need to be updated to remove references to this.

Which is frustrating because I've got an AWS OpenSearch Domain and I'm a little bit stumped how to actually debug an issue I'm having with the security controls and it seemed like opensearch-cli curl would have helped me because it would have handled the SIGv4 signing for me.

dblock commented 1 year ago

I see two problems:

  1. The CLI is broken. Appreciate any time anyone can spend fixing it in ways that doesn't break again. Thank you for reporting this.
  2. @ajacques you're saying you're having some other issue and need a working curl with sigv4? Feel free to open a bug or ask on the public slack any questions and we'll do our best to help you. For Sigv4 I typically use awscurl, it "just works" (TM) to query OpenSearch. This might also be helpful: https://code.dblock.org/2022/07/11/making-sigv4-authenticated-requests-to-managed-opensearch.html
peternied commented 9 months ago

[Triage - attendees 1 2 3 4 5] @ajacques Thanks for filing this issue, we agree with @dblock this would be good to be fixed, we'd welcome a pull request.