-
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
fix database manager with multiple pipelines #12862
fix database manager with multiple pipelines #12862
Conversation
5e2091a
to
222d807
Compare
|
||
case | ||
when days_without_update >= 30 | ||
if @states[database_type].is_eula && @states[database_type].plugins.size > 0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(5) this check ensures Logstash can use CC database indefinitely. we only notify plugins to do expiry action when the plugin is using EULA and age >= 30
"Please check the network settings and allow Logstash accesses the internet to download the latest database, "\ | ||
"or switch to offline mode (:database => PATH_TO_YOUR_DATABASE) to use a self-managed database "\ | ||
"which you can download from https://dev.maxmind.com/geoip/geoip2/geolite2/ ") | ||
@states[database_type].plugins.dup.each { |plugin| plugin.expire_action if plugin } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(4) the actual expiry logic is in plugin
…ple_pipelines � Conflicts: � x-pack/lib/filters/geoip/database_manager.rb � x-pack/lib/filters/geoip/database_metadata.rb � x-pack/lib/filters/geoip/util.rb � x-pack/spec/filters/geoip/database_manager_spec.rb � x-pack/spec/filters/geoip/database_metadata_spec.rb
…ple_pipelines # Conflicts: # x-pack/lib/filters/geoip/database_manager.rb # x-pack/spec/filters/geoip/database_manager_spec.rb
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this review suggests some changes so that the implementation is done in a more Ruby-like way, namely adopting some patterns like the Observer and Singleton patterns.
A couple of notes of things we should address but that don't block this PR:
This message gets printed every day, and in that mindset it's confusing to say "geoip plugin will stop / will tag", as it's been doing it already for perhaps days or weeks
And:
Or even in some cases there's only 1 message, but still gets identified with a pipeline (rufus changed to execute every 30 seconds):
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
tested manually multiple scenarios, online and offline, with > 20 pipelines.
Logstash + the plugin were always able to either download or delete the database correctly.
I will update plugin
Can you explain your setup? I have tested 10x pipelines. Each pipeline prints the corresponding msg. How do you set it to n pipelines but only one pipeline is identified? |
I found two issues.
|
fix database expired before startup fix fallback to CC database issue
One final remark: when restarting logstash when offline after it deleted an expired database, we can't see any information that the plugins will not enrich data. if you're familiar with the implementation you can figure out that the following line tells you that:
Can we also throw a warning in this situation? the user should see that they're starting a new pipeline that won't enrich data |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 🚀
@kaisecheng I don't see master failing on the tests that this PR is failing in, can you do a check and find if these changes are causing an intengration test to fail? |
the integration test failed because we don't have a match geoip plugin release. |
…bump version to 7.2.1
jenkins test this please |
1 similar comment
jenkins test this please |
This PR adds support to geoip multiple pipelines which have a single instance to manage database download to avoid individual download per pipeline
* master: (41 commits) Test: resolve integration failure due ECS mode (elastic#13044) Feat: event factory support (elastic#13017) Doc: Add geoip database API to node stats (elastic#13019) Add geoip database metrics to /node/stats API (elastic#13004) ecs: on-by-default plus docs (elastic#12830) ispec: fix cross-spec leak from fatal error integration specs (elastic#13002) Fix UBI source URL (elastic#13008) update fpm to allow pkg creation on jdk11+jruby 9.2 (elastic#13005) Add unit test to grant that production aliases correspond to a published RubyGem (elastic#12993) Fix logstash.bat not setting exit code (elastic#12948) Use the OS separator to invoke gradlew from Rake script (elastic#13000) Allow per-pipeline config of ECS Compatibility mode via Central Management (elastic#12861) Update jinja2 dependency in docker build (elastic#12994) fix database manager with multiple pipelines (elastic#12862) Fix Reflections stack traces when process yml files in classpath and debug is enabled (elastic#12991) Fix/log4j routing to avoid create spurious file (elastic#12965) Deps: update JRuby to 9.2.19.0 (elastic#12989) Doc: Add tip for checking for existing field (elastic#12899) Added test to cover the installation of aliased plugins (elastic#12967) CI: Update logstash_release.json after 7.3.12 (elastic#12986) ...
This PR goes together with plugin PR logstash-plugins/logstash-filter-geoip#181
To the reviewer: I rewrote the whole flow of geoip database service. So, it is easier to review the raw file.
Please check here
Background
Currently, each geoip pipeline creates one DatabaseManager to download database. To prevent duplicate download, this PR changes DatabaseManager to singleton to make sure only one instance manages database and one scheduler downloads database.
Acceptance criteria
metadata example
Fixed: #12856