Introduce LS_JAVA_HOME environment variable#13204
Conversation
roaksoax
left a comment
There was a problem hiding this comment.
The actual changes look good to me. I'll approve on that basis, however, could you please make sure all the comments about messages are addressed before landing?
| if [ -x "$LS_JAVA_HOME/bin/java" ]; then | ||
| JAVACMD="$LS_JAVA_HOME/bin/java" | ||
| if [ -d "${LOGSTASH_HOME}/${BUNDLED_JDK_PART}" -a -x "${LOGSTASH_HOME}/${BUNDLED_JDK_PART}/bin/java" ]; then | ||
| echo "WARNING, using LS_JAVA_HOME while Logstash distribution comes with a bundled JDK" |
There was a problem hiding this comment.
I believe the format for warnings is "WARNING: ". You are using a ',' instead. So should be:
WARNING: Using LS_JAVA_HOME env variable while Logstash distribution comes with a bundled JDK ()"
I made a couple of minor adjustments. Would be nice to specify which version of the JDK is bundled (the full version). Lets use end of sentence punctuation here as well.
There was a problem hiding this comment.
One way to print the full version of the bundled JDK could be to execute the "${LOGSTASH_HOME}/${BUNDLED_JDK_PART}/bin/java -version" . But this produces 3 lines of output after the "WARNING:" line, it's not inlined.
|
|
||
| if [ ! -x "$JAVACMD" ]; then | ||
| echo "could not find java; set JAVA_HOME or ensure java is in PATH" | ||
| echo "could not find java; set LS_JAVA_HOME or ensure java is in PATH" |
There was a problem hiding this comment.
Should the first letter be upper cased? (It is a new sentence(. Also, I believe we should use proper punctuation, so should likely need a '.' at the end of all sentences.
| echo "WARNING, using LS_JAVA_HOME while Logstash distribution comes with a bundled JDK" | ||
| fi | ||
| else | ||
| echo "Invalid LS_JAVA_HOME, doesn't contain bin/java executable" |
There was a problem hiding this comment.
missing end of sentence punctuation.
| set JAVA="%LS_JAVA_HOME%\bin\java.exe" | ||
| echo Using LS_JAVA_HOME defined java: %LS_JAVA_HOME% | ||
| if exist "%LS_HOME%\jdk" ( | ||
| echo WARNING, using LS_JAVA_HOME while Logstash distribution comes with a bundled JDK |
There was a problem hiding this comment.
Incorrect format, plus missing punctuation.
| JAVACMD_TEST=`command -v java` | ||
| if [ -n "$JAVA_HOME" ]; then | ||
| if [ -n "$LS_JAVA_HOME" ]; then | ||
| echo "Using LS_JAVA_HOME defined java: ${LS_JAVA_HOME}" |
| If {ls} doesn't find `LS_JAVA_HOME` it tries to fall back on `JAVA_HOME` but this behaviour | ||
| could be subject to be removed. |
There was a problem hiding this comment.
| If {ls} doesn't find `LS_JAVA_HOME` it tries to fall back on `JAVA_HOME` but this behaviour | |
| could be subject to be removed. | |
| If {ls} doesn't find `LS_JAVA_HOME`, it tries to fall back to `JAVA_HOME`. Note that this behavior is experimental and could be subject to removal in later releases. |
| On some Linux systems, you may need to have the `JAVA_HOME` environment | ||
| If {ls} doesn't find `LS_JAVA_HOME` it tries to fall back on `JAVA_HOME` but this behaviour | ||
| could be subject to be removed. | ||
| On some Linux systems, you may need to have the `LS_JAVA_HOME` environment |
There was a problem hiding this comment.
| On some Linux systems, you may need to have the `LS_JAVA_HOME` environment | |
| On some Linux systems, you may need to have the `LS_JAVA_HOME` environment |
There was a problem hiding this comment.
Suggest return to break up text block for easier parsing.
|
@karenzone may I ask you a quick eye on the docs part of this PR, located in file |
Logstash leverage JAVA_HOME environment variable to give the user the ability to explicitly select a JDK he woudl use. JAVA_HOME is a variable shared by all applccation that use a JDK, so to avoid conflicts with other services and let the user to select a specific JDK only for Logstash execution, this commit introduce the LS_JAVA_HOME that takes precedence over the standard variable.
128bd61 to
d9beb59
Compare
This commit modifies the launch scripts to take care of the LS_JAVA_HOME giving precedence over the JAVA_HOME, which is still used it the first is not found.
Release notes
Logstash's launch script support
LS_JAVA_HOMEas an override of environment variable overJAVA_HOME.It's the path to an installed JDK to be used to launch Logstash's service and support tools.
JAVA_HOMEis going to be removed, however ifLS_JAVA_HOMEis not specified then Logstash still looks forJAVA_HOME.What does this PR do?
This PR modifies the launch scripts to take care of the
LS_JAVA_HOMEgiving precedence over theJAVA_HOME, which is still used it the first is not found.Why is it important/What is the impact to the user?
The existing
JAVA_HOMEis an environment variable globally used by all JVM applications present on a host.With the introduction of
LS_JAVA_HOMEthe user is able to customize the JDK used by Logstash without changing the globalJAVA_HOME. It introduces a layer of separation, permitting a more fine grained control of the JDK customization for Logstash.Checklist
I have commented my code, particularly in hard-to-understand areasI have made corresponding change to the default configuration files (and/or docker env variables)I have added tests that prove my fix is effective or that my feature worksAuthor's Checklist
LS_JAVA_HOMEon Windows and LinuxHow to test this PR locally
bashset theLS_JAVA_HOMEexport LS_JAVA_HOME=/path/to/jdkand run `bin/logstash -e "input{stdin{}} output {stdout{codec => rubydebug}}"set LS_JAVA_HOME="C:\path\to\JDK"and run `bin\logstash -e "input{stdin{}} output {stdout{codec => rubydebug}}"In both cases it prints the the JDK used and must correspond to what was selected, verify also with rest API
curl -XGET 'localhost:9600/_node/jvm?pretty'Related issues
Use cases
Screenshots
Logs