From a820634a2e10564b63c0f13d6669dc91b4fe06b9 Mon Sep 17 00:00:00 2001 From: kaisecheng <69120390+kaisecheng@users.noreply.github.com> Date: Fri, 14 May 2021 10:39:28 +0200 Subject: [PATCH] Geoip disable database manager (#12905) (#12907) --- x-pack/lib/filters/geoip/database_manager.rb | 3 +++ x-pack/spec/filters/geoip/database_manager_spec.rb | 9 ++++++--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/x-pack/lib/filters/geoip/database_manager.rb b/x-pack/lib/filters/geoip/database_manager.rb index c14b8b66c2b..6c14d7303a8 100644 --- a/x-pack/lib/filters/geoip/database_manager.rb +++ b/x-pack/lib/filters/geoip/database_manager.rb @@ -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) @@ -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, "\ diff --git a/x-pack/spec/filters/geoip/database_manager_spec.rb b/x-pack/spec/filters/geoip/database_manager_spec.rb index 2e388086664..a172657222b 100644 --- a/x-pack/spec/filters/geoip/database_manager_spec.rb +++ b/x-pack/spec/filters/geoip/database_manager_spec.rb @@ -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