logstash-plugins / logstash-filter-geoip

Apache License 2.0
64 stars 82 forks source link

Cannot start clean install with geoip DB download disabled #222

Closed TheVastyDeep closed 8 months ago

TheVastyDeep commented 9 months ago

logstash 8.12.2 from yum update run on command line with bundled plugin and JVM

4.14.336-256.559.amzn2.x86_64 #1 SMP Tue Feb 13 09:50:28 UTC 2024 x86_64 x86_64 x86_64 GNU/Linux

I normally run logstash on the command line using a shell script that creates an empty --path.data on every execution

#!/bin/sh

TMPDIR=`mktemp -d`
trap "/bin/rm -rf $TMPDIR" EXIT

/usr/share/logstash/bin/logstash --path.data $TMPDIR \
    --path.settings /etc/logstash "$@"

If I set xpack.geoip.downloader.enabled: false in logstash.yml` then logstash cannot start, because it assumes that there is a geoip_database_management directory underneath the (empty) --path.data. It fails with

[FATAL][logstash.runner          ] An unexpected error occurred! {:error=>#<Errno::ENOENT: No such file or directory - /tmp/tmp.Pkpqsv1mKW/geoip_database_management>, 
:backtrace=>["org/jruby/RubyDir.java:147:in `initialize'", 
"org/jruby/RubyClass.java:917:in `new'", 
"org/jruby/RubyDir.java:492:in `children'", 
"org/jruby/RubyDir.java:487:in `children'", 
"/usr/share/logstash/x-pack/lib/geoip_database_management/manager.rb:146:in `clean_up_database'", 
"/usr/share/logstash/x-pack/lib/geoip_database_management/manager.rb:64:in `initialize'",
...

It looks like the directory is created when database_download is called, not when the DataPath is initialized, so when clean_up_databases is called nothing exists.

This can be reproduced with any empty --path.data

mkdir /tmp/foo
/usr/share/logstash/bin/logstash --path.data /tmp/foo --path.settings /etc/logstash -e 'input { stdin {} }'