Skip to content

Commit

Permalink
Geoip disable database manager (#12905) (#12907)
Browse files Browse the repository at this point in the history
  • Loading branch information
kaisecheng authored May 14, 2021
1 parent be6024e commit a820634
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
3 changes: 3 additions & 0 deletions x-pack/lib/filters/geoip/database_manager.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ def initialize(geoip, database_path, database_type, vendor_path)
@geoip = geoip
self.class.prepare_cc_db
@mode = database_path.nil? ? :online : :offline
@mode = :disabled # This is a temporary change that turns off the database manager until it is ready for general availability.
@database_type = database_type
@database_path = patch_database_path(database_path)

Expand All @@ -49,6 +50,8 @@ def initialize(geoip, database_path, database_type, vendor_path)
# check database update periodically. trigger `call` method
@scheduler = Rufus::Scheduler.new({:max_work_threads => 1})
@scheduler.every('24h', self)
elsif @mode == :disabled
# The plan is to use CC database in Logstash 7.x and enable EULA database in 8
else
logger.info "GeoIP database path is configured manually so the plugin will not check for update. "\
"Keep in mind that if you are not using the database shipped with this plugin, "\
Expand Down
9 changes: 6 additions & 3 deletions x-pack/spec/filters/geoip/database_manager_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,12 @@
expect(mock_metadata).to receive(:updated_at).and_return((Time.now - (60 * 60 * 24 * 26)).to_i)
expect(mock_metadata).to receive(:cc?).and_return(false)
expect(mock_geoip_plugin).to receive(:terminate_filter).never
expect(LogStash::Filters::Geoip::DatabaseManager).to receive(:logger).at_least(:once).and_return(logger)
expect(logger).to receive(:warn)
expect(logger).to receive(:info)

if db_manager.instance_variable_get(:@mode) != :disabled
expect(LogStash::Filters::Geoip::DatabaseManager).to receive(:logger).at_least(:once).and_return(logger)
expect(logger).to receive(:warn)
expect(logger).to receive(:info)
end

db_manager.send(:check_age)
end
Expand Down

0 comments on commit a820634

Please sign in to comment.