-
Notifications
You must be signed in to change notification settings - Fork 30
Description
Summary
I have installed gems to custom location using fluent-gem install --install-dir to a custom path /opt/additionalgems.
I am updating the GEM_PATH environment variable with this path, but instead of loading gems installed in this directory, fluentd is still picking up gems from the default path.
Root cause
I am running /usr/sbin/fluentd to run fluentd application in my docker entrypoint script. And upon checking carefully, I realized that /usr/sbin/fluentd is a wrapper for /opt/fluent/bin/fluentd and this wrapper code is setting GEM_PATH env to default path.
Due to the fact, regardless of whatever the environment variable is set by the user, fluentd process will always load gems from the default path which is hard-coded in the wrapper.
Wrapper script:
#!/opt/fluent/bin/ruby
ENV["GEM_HOME"]="/opt/fluent/lib/ruby/gems/3.4.0/"
ENV["GEM_PATH"]="/opt/fluent/lib/ruby/gems/3.4.0/" # ---> HARD-CODED
ENV["FLUENT_CONF"]="/etc/fluent/fluentd.conf"
ENV["FLUENT_CONF_INCLUDE_DIR"]="/etc/fluent/conf.d"
ENV["FLUENT_PLUGIN"]="/etc/fluent/plugin"
ENV["FLUENT_SOCKET"]="/var/run/fluent/fluentd.sock"
if ARGV.include?("--version")
require "/opt/fluent/share/config"
Dir.glob("/opt/fluent/lib/ruby/**/gems/**/fluent/version.rb").each do |v|
require v.delete_suffix(".rb")
end
puts "fluent-package #{PACKAGE_VERSION} fluentd #{Fluent::VERSION} (#{FLUENTD_REVISION})"
exit 0
end
if RUBY_PLATFORM =~ /linux/
prevent_duplicate_launch = system("systemctl", "is-active", "fluentd", out: IO::NULL)
if prevent_duplicate_launch
if ["-c", "--config", "--dry-run", "-h", "--help", "--show-plugin-config"].none? {|allowing_opt| ARGV.include? allowing_opt}
puts("Error: Can't start duplicate Fluentd instance with the default config.")
if ARGV.include?("-v")
puts("To take the version, please use '--version', not '-v' ('--verbose').")
end
puts <<EOS
To start Fluentd, please do one of the following:
(Caution: Please be careful not to start multiple instances with the same config.)
- Stop the Fluentd service 'fluentd'.
- Specify the config path explicitly by '-c' ('--config').
EOS
exit 2
end
end
end
load "/opt/fluent/bin/fluentd"Ask
I was wondering if there is a workaround for this? Any other parameter or approach that can be used to encourage fluentd to load plugins from the custom path.
FYI: I have tried modifying the wrapper and that does work. But i am looking for a solution that does not involve modifying the wrapper script.