diff --git a/app/models/metric/purging.rb b/app/models/metric/purging.rb index 0118cad2c4c..49d7e23d24a 100644 --- a/app/models/metric/purging.rb +++ b/app/models/metric/purging.rb @@ -40,12 +40,17 @@ def self.purge_timer(ts, interval) :class_name => name, :method_name => "purge_#{interval}", :role => "ems_metrics_processor", - :queue_name => "ems_metrics_processor" + :queue_name => "ems_metrics_processor", + :msg_timeout => msg_timeout ) do |_msg, find_options| find_options.merge(:args => [ts]) end end + def self.msg_timeout + ::Settings.performance.history.queue_timeout.to_i_with_method + end + def self.purge_window_size VMDB::Config.new("vmdb").config.fetch_path(:performance, :history, :purge_window_size) || 1000 end diff --git a/app/models/vmdb_metric/purging.rb b/app/models/vmdb_metric/purging.rb index 1e0286a3e4e..de6c6d312d5 100644 --- a/app/models/vmdb_metric/purging.rb +++ b/app/models/vmdb_metric/purging.rb @@ -34,6 +34,7 @@ def purge_timer(value, interval) :method_name => "purge_#{interval}", :role => "database_operations", :queue_name => "generic", + :msg_timeout => msg_timeout, ) do |_msg, find_options| find_options.merge(:args => [value]) end @@ -86,5 +87,9 @@ def purge_by_date(older_than, interval, window = nil, &block) _log.info("Purging #{interval} metrics older than [#{older_than}]...Complete - Deleted #{total} records") total end + + def msg_timeout + ::Settings.database.metrics_history.queue_timeout.to_i_with_method + end end end diff --git a/config/settings.yml b/config/settings.yml index b8cf7834a35..daac692f179 100644 --- a/config/settings.yml +++ b/config/settings.yml @@ -87,6 +87,7 @@ :keep_hourly_metrics: 6.months :purge_schedule: "50 * * * *" :purge_window_size: 100000 + :queue_timeout: 20.minutes :drift_states: :history: :keep_drift_states: 6.months @@ -1043,6 +1044,7 @@ :keep_hourly_performances: 6.months :keep_realtime_performances: 4.hours :purge_window_size: 1000 + :queue_timeout: 20.minutes :host_overhead: :memory: 2.01.percent :cpu: 0.15.percent diff --git a/spec/models/metric/purging_spec.rb b/spec/models/metric/purging_spec.rb index 32c6e5e89f4..792cf913acf 100644 --- a/spec/models/metric/purging_spec.rb +++ b/spec/models/metric/purging_spec.rb @@ -1,4 +1,22 @@ describe Metric::Purging do + let(:settings) do + { + :performance => { + :history => { + :keep_daily_performance => "6.months", + :keep_hourly_performance => "6.months", + :keep_realtime_performance => "4.hours", + :purge_window_size => 1000, + :queue_timeout => "20.minutes" + } + } + } + end + + before do + stub_settings(settings) + end + context "::Purging" do it "#purge_all_timer" do EvmSpecHelper.create_guid_miq_server_zone @@ -12,6 +30,7 @@ q.each do |qi| expect(qi).to have_attributes( :class_name => described_class.name, + :msg_timeout => 1200 ) end @@ -24,18 +43,6 @@ let(:vm1) { FactoryGirl.create(:vm_vmware) } let(:vm2) { FactoryGirl.create(:vm_vmware) } let(:host) { FactoryGirl.create(:host) } - let(:settings) do - { - :performance => { - :history => { - :keep_daily_performance => "6.months", - :keep_hourly_performance => "6.months", - :keep_realtime_performance => "4.hours", - :purge_window_size => 1000 - } - } - } - end before do stub_settings(settings)