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
Cannot override JVM options for plugins #381
Comments
Could you share the plugin declaration to reproduce this error, please? Thanks. |
I try to keep everything in Hiera - so my puppet code related to plugins is this: $hiera_pluginlist = lookup({name => 'logstash::pluginlist', default_value => undef, merge => deep})
if $hiera_pluginlist {
create_resources('logstash::plugin', $hiera_pluginlist)
} And in my heira data I have this: logstash::pluginlist:
logstash-filter-translate:
ensure: present
environment: LS_JAVA_OPTS="-Xms1g -Xmx1g" If it matters, running the following command in a terminal on the same node works just fine: |
Thanks. That's really interesting. Check out the debug output:
The command being |
This matters a lot. 💯 Thanks for providing such a good reproduction. Here's what I pulled out of my process list when running successfully from the shell:
...and here's what is run when using Puppet:
The fail state contains this nasty piece of work: That string quoting not our friend. |
So, if you remove the quotes from your Hiera YAML, it works:
The
But in your case, Hiera is sending the equivalent of this:
It not super intuitive, with so many layers of string handling: YAML -> Hiera -> Puppet -> Shell. Here's an example of the problem in pure Puppet: # example.pp
exec { 'test':
command => '/bin/echo $CANARY > /tmp/target',
provider => 'shell',
environment => 'CANARY=a yellow bird',
}
# example.pp
exec { 'test':
command => '/bin/echo $CANARY > /tmp/target',
provider => 'shell',
environment => 'CANARY="a yellow bird in a cage"',
}
|
Ok - I'll give it a go tomorrow when I'm back in the office, based on everything here I expect it should be fine. One last point to make though - back on previous versions of the puppet module and elastic components (when it was still LS_JVM_OPTIONS) the quotes didn't cause any problems. When I upgraded everything, the only change I made (besides new versions) was replacing LS_JVM_OPTIONS with LS_JAVA_OPTS - same puppet code, same hiera data, same quotes, etc. Quotes didn't cause a problem before, but they do now. Thanks for the help. |
I understand. The plugin command (which is a shell script) must have changed its behaviour. I updated the README and comments here to be correct for the new way. Sorry you hit this and thanks again for the excellent report. |
Under logstash 5, I was able to set the environment parameter on plugin resources to do something like:
LS_JVM_OPTIONS="-Xms1g -Xmx1g"
And all was good. Having now upgraded to logstash 6, the LS_JVM_OPTIONS environment variable no longer functions and was replaced with LS_JAVA_OPTS, which should work in the same way. However, when I pass an environment variable of LS_JAVA_OPTS="-Xms1g -Xmx1g" to the plugin resource, I get errors when puppet runs:
Notice: /Stage[main]/Profile::Logstash/Logstash::Plugin[logstash-filter-translate]/Exec[install-logstash-filter-translate]/returns: Error: Could not find or load main class "-Xms1g"
Error: '/usr/share/logstash/bin/logstash-plugin install logstash-filter-translate' returned 1 instead of one of [0]
Error: /Stage[main]/Profile::Logstash/Logstash::Plugin[logstash-filter-translate]/Exec[install-logstash-filter-translate]/returns: change from notrun to 0 failed: '/usr/share/logstash/bin/logstash-plugin install logstash-filter-translate' returned 1 instead of one of [0]
This would also probably be a good time to update the example config here: https://github.com/elastic/puppet-logstash/blob/master/manifests/plugin.pp#L31 to use the LS_JAVA_OPTS variable.
The text was updated successfully, but these errors were encountered: