-
Notifications
You must be signed in to change notification settings - Fork 3.5k
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
LS_JAVA_OPTS env var could lead to duplication of java options #16078
Comments
Tested with andrea:logstash_andsel (tags/v8.13.2) % export LS_JAVA_OPTS="-Dio.netty.allocator.maxOrder=6" && bin/Logstash -e "input{stdin{}} output{stdout{codec => rubydebug}}"
Using system java: /Users/andrea/.sdkman/candidates/java/current/bin/java
.....
[2024-04-12T10:00:56,760][INFO ][logstash.runner ] JVM bootstrap flags: [-Xms1g, -Xmx1g, -Djava.awt.headless=true, -Dfile.encoding=UTF-8,
-Djruby.compile.invokedynamic=true, -XX:+HeapDumpOnOutOfMemoryError, -Djava.security.egd=file:/dev/urandom,
-Dlog4j2.isThreadContextMapInheritable=true, -Dlogstash.jackson.stream-read-constraints.max-string-length=200000000,
-Dlogstash.jackson.stream-read-constraints.max-number-length=10000,
-Dio.netty.allocator.maxOrder=6,
-Djruby.regexp.interruptible=true, -Djdk.io.File.enableADS=true,
--add-exports=jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED,
--add-exports=jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED,
--add-exports=jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED,
--add-exports=jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED,
--add-exports=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED,
--add-opens=java.base/java.security=ALL-UNNAMED,
--add-opens=java.base/java.io=ALL-UNNAMED,
--add-opens=java.base/java.nio.channels=ALL-UNNAMED,
--add-opens=java.base/sun.nio.ch=ALL-UNNAMED,
--add-opens=java.management/sun.management=ALL-UNNAMED] The env var However all Logstash settings are exposed as environment variables (
Running a simple % docker run -ti --rm -e LS_JAVA_OPTS="-Dio.netty.allocator.maxOrder=14" docker.elastic.co/logstash/logstash:8.13.2 bash
logstash@8d9113afd0b1:~$ env
HOSTNAME=8d9113afd0b1
ELASTIC_CONTAINER=true
PWD=/usr/share/logstash
HOME=/usr/share/logstash
LANG=en_US.UTF-8
TERM=xterm
LS_JAVA_OPTS=-Dls.cgroup.cpuacct.path.override=/ -Dls.cgroup.cpu.path.override=/ -Dio.netty.allocator.maxOrder=14
SHLVL=1
LC_ALL=en_US.UTF-8
PATH=/usr/share/logstash/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
_=/usr/bin/env
logstash@8d9113afd0b1:~$ So I think it's related to the fact that logstash/tools/jvm-options-parser/src/main/java/org/logstash/launchers/JvmOptionsParser.java Line 114 in 9483ee0
|
Description of the problemThe root cause is related to the fact that the logstash/tools/jvm-options-parser/src/main/java/org/logstash/launchers/JvmOptionsParser.java Line 179 in 9483ee0
So it adds the entire content of the environment variable as whole. When it's launched from local host outside any container, with just one value, it works expected. However examining the value of LS_JAVA_OPTS inside the container:
% docker run -ti --rm -e LS_JAVA_OPTS="-Dio.netty.allocator.maxOrder=13" docker.elastic.co/logstash/logstash:8.13.2 bash
logstash@0729b9bb4079:~$ /usr/share/logstash/jdk/bin/jshell
Apr 12, 2024 9:10:17 AM java.util.prefs.FileSystemPreferences$1 run
INFO: Created user preferences directory.
| Welcome to JShell -- Version 17.0.10
| For an introduction type: /help intro
jshell> System.getenv("LS_JAVA_OPTS")
$1 ==> "-Dls.cgroup.cpuacct.path.override=/ -Dls.cgroup.cpu.path.override=/ -Dio.netty.allocator.maxOrder=13"
jshell> become evident that that the |
Environment variable
LS_JAVA_OPTS
is supposed to take the precedence to overwrite the default jvm settings, however, setting it to-Dio.netty.allocator.maxOrder=14 -Xmx2g -Xms2g
is unable to changeio.netty.allocator.maxOrder
to14
, instead11
is appended at the end.version
8.13.2
Reproduce steps
You can see
-Dio.netty.allocator.maxOrder=11
appended to the end in log.Log
The text was updated successfully, but these errors were encountered: