Skip to content

Some elasticsearch-cli tools could not be run not from ES_HOME #39937

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

Merged
merged 6 commits into from
Mar 14, 2019

Conversation

andrershov
Copy link
Contributor

The issue was found when working on elasticsearch-node tool.

  1. Explicitly set path.data to relative to ES_HOME path in elasticsearch.yml.
  2. Run elasticsearch from any directory. Elasticsearch is able to correctly start.
  3. Stop Elasticsearch.
  4. Run elasticsearch-node unsafe-bootstrap not from ES_HOME directory. It will fail with the following exception
Exception in thread "main" ElasticsearchException[no node folder is found in data folder(s), node has not been started yet?]

This issue happens because elasticsearch-node uses elasticsearch-cli script that does not cd to ES_HOME before running the tool. elasticsearch launch script on the hand cd's to ES_HOME before running es java process.
This PR fixes the issue and adds a new test.
Also tests >=100 are renamed because alphabetic order does not work for them.

@andrershov andrershov added >bug :Delivery/Packaging RPM and deb packaging, tar and zip archives, shell and batch scripts v7.0.0 v8.0.0 v7.2.0 labels Mar 11, 2019
@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-core-infra

Copy link
Member

@jasontedor jasontedor left a comment

Choose a reason for hiding this comment

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

Good change. Let's remove the cd from bin/elasticsearch(.bat)?.

@andrershov
Copy link
Contributor Author

andrershov commented Mar 12, 2019

@jasontedor sorry, I don't understand why do you propose to remove cd ES_HOME from bin/elasticsearch. bin/elasticsearch is not based on bin/elasticsearch-cli, so cd is still needed there

@andrershov
Copy link
Contributor Author

run elasticsearch-ci/bwc

@jasontedor
Copy link
Member

jasontedor commented Mar 12, 2019

Sorry for causing the confusion. What I mean explicitly is, let us relocate this global to elasticsearch-env, and then remove this from elasticsearch and elasticsearch-cli. Does that help?

@rjernst
Copy link
Member

rjernst commented Mar 12, 2019

Why do we need to cd at all? Shouldn't ensuring relative paths work be done in Environment, eg by making the path to path.data relative to ES_HOME if it is not absolute? I don't think we should rely on the working directory at all.

@jasontedor
Copy link
Member

We need the working directory to be correct for ES for example to set the GC logs path relative to home. It’s not possible otherwise.

@andrershov
Copy link
Contributor Author

Thanks, @jasontedor, I've made requested changes, can you please take a look?

@andrershov andrershov requested a review from jasontedor March 13, 2019 12:39
Copy link
Member

@jasontedor jasontedor left a comment

Choose a reason for hiding this comment

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

LGTM.

@andrershov andrershov merged commit 2ffc293 into elastic:master Mar 14, 2019
andrershov pushed a commit that referenced this pull request Mar 14, 2019
This commit adds cd $ES_HOME to elasticsearch-env and removes it from
elasticsearch. This way, both elasticsearch and elasticsearch-cli are
executed with the working directory set to $ES_HOME. The need for the
fix arose from the following bug:
1. Explicitly set path.data to relative to ES_HOME path in
elasticsearch.yml.
2. Run elasticsearch from any directory. Elasticsearch is able to
correctly start.
3. Stop elasticsearch.
4. Run elasticsearch-node unsafe-bootstrap, not from ES_HOME directory.
It will fail with an exception.
This commit fixes the issue and adds a new test.

This PR fixes the issue and adds a new test.
Also tests >=100 are renamed because alphabetic order does not work for
them.

(cherry picked from commit 2ffc293)
andrershov pushed a commit to andrershov/elasticsearch that referenced this pull request Mar 14, 2019
This commit adds cd $ES_HOME to elasticsearch-env and removes it from
elasticsearch. This way, both elasticsearch and elasticsearch-cli are
executed with the working directory set to $ES_HOME. The need for the
fix arose from the following bug:
1. Explicitly set path.data to relative to ES_HOME path in
elasticsearch.yml.
2. Run elasticsearch from any directory. Elasticsearch is able to
correctly start.
3. Stop elasticsearch.
4. Run elasticsearch-node unsafe-bootstrap, not from ES_HOME directory.
It will fail with an exception.
This commit fixes the issue and adds a new test.

This PR fixes the issue and adds a new test.
Also tests >=100 are renamed because alphabetic order does not work for
them.

(cherry picked from commit 2ffc293)
@jasontedor
Copy link
Member

@andrershov I think that you missed backporting this to 7.x. Also note whether or not #40083 is applicable, and you'll need #40118 too. I've added the backport pending label to reflect this.

andrershov pushed a commit that referenced this pull request Mar 18, 2019
This commit adds cd $ES_HOME to elasticsearch-env and removes it from
elasticsearch. This way, both elasticsearch and elasticsearch-cli are
executed with the working directory set to $ES_HOME. The need for the
fix arose from the following bug:
1. Explicitly set path.data to relative to ES_HOME path in
elasticsearch.yml.
2. Run elasticsearch from any directory. Elasticsearch is able to
correctly start.
3. Stop elasticsearch.
4. Run elasticsearch-node unsafe-bootstrap, not from ES_HOME directory.
It will fail with an exception.
This commit fixes the issue and adds a new test.

This PR fixes the issue and adds a new test.
Also tests >=100 are renamed because alphabetic order does not work for
them.

(cherry picked from commit 2ffc293
with fixes by #40083 and #40118)
@andrershov andrershov removed the request for review from DaveCTurner March 18, 2019 15:32
@andrershov
Copy link
Contributor Author

@jasontedor thank you for noticing this, I've mistakenly pushed 7.x to my fork instead of this repo. Fixed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
>bug :Delivery/Packaging RPM and deb packaging, tar and zip archives, shell and batch scripts Team:Delivery Meta label for Delivery team v7.0.0-rc1 v7.2.0 v8.0.0-alpha1
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants