Skip to content
This repository has been archived by the owner on May 18, 2020. It is now read-only.

env variables ES_HOME and ES_PATH_CONF lead to incorrect config being used and might even corrupt existing indizes #82

Open
AFurtner opened this issue Feb 8, 2019 · 1 comment

Comments

@AFurtner
Copy link

AFurtner commented Feb 8, 2019

Embedded ES will not grab the wrong configuration like ports, data dirs or other stuff put into Settings when the environment variables ES_HOME and/or ES_PATH_CONF are set.

I discovered this on Windows were I recently installed a new ES6.5.4 via the new .msi-Installer.
Because I had an older (unzipped) "installation" before which indizes I wanted to upgrade, I supplied custom config and data dirs in the Installer.
Seems this installed global System/User wide environment variables ES_HOME and ES_PATH_CONF
pointing to the configured directories. I'm pretty sure that I did not set those environment vars myself.
The usual startup scripts on windows (and on a superficial inspection on *nix, too) use these environment vars to bootstrap all other config stuff.
Not sure if Linux package installation does the same thing, but other installers might?!

So when starting up the unzipped elastic instance and running the start script, (all) settings supplied by the builder will be useless, as the startup script even changes directory to the other installed instance pointed to by ES_HOME and also grabs all config from the config-dir in ES_PATH_CONF.

This might even corrupt existing indizes when running integration tests if the user is not aware of this behaviour and did not specify other names for test indizes.

As a fix I'd suggest to remove those preset (global/user wide) environment variables from the the forked process's environment, starting around here:

and add something like:

if (builder.environment().containsKey("ES_HOME")) {
    builder.environment().remove("ES_HOME");
}
if (builder.environment().containsKey("ES_PATH_CONF")) {
    builder.environment().remove("ES_PATH_CONF");
}

or put the "correct" pathes in there (like the just created/configured install and config directories).
Removing seems (as of now) not to be problematic for the zipped distributions, as those starter scripts do a fair amount of guessing the bootstrap directories themselves if they are not supplied.

At least you might want to insert a warning/comment about those environment variables into the README.md?

[EDITED: removed "not" in the 1st sentence]

@AFurtner AFurtner changed the title env variables ES_HOME and ES_PATH_CONF might lead to incorrect config being used and potentially even corrupt other env variables ES_HOME and ES_PATH_CONF lead to incorrect config being used and might even corrupt existing indizes Feb 8, 2019
AFurtner pushed a commit to AFurtner/embedded-elasticsearch that referenced this issue Feb 8, 2019
…ment vars from environment for forked embedded ES process
@AFurtner
Copy link
Author

AFurtner commented Feb 8, 2019

I added a PR with suggested quick fix. I admit I did not test it, as i have not build embedded-elastic from source yet ;-)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant