Skip to content

Commit

Permalink
Merge pull request #15312 from jntullo/bz/purge_timeout
Browse files Browse the repository at this point in the history
Increase timeout for metric purging
  • Loading branch information
gtanzillo committed Jun 14, 2017
2 parents 1adc252 + 75f603c commit 6271921
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 16 deletions.
5 changes: 5 additions & 0 deletions app/models/metric/purging.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,18 @@ def self.purge_timer(ts, interval)
:class_name => name,
:method_name => "purge_#{interval}",
:args => [ts],
:msg_timeout => msg_timeout
)
end

def self.purge_window_size
::Settings.performance.history.purge_window_size
end

def self.msg_timeout
::Settings.performance.history.queue_timeout.to_i_with_method
end

def self.purge_scope(older_than, interval)
scope = interval == 'realtime' ? Metric : MetricRollup.where(:capture_interval_name => interval)
scope.where(scope.arel_table[:timestamp].lteq(older_than))
Expand Down
7 changes: 6 additions & 1 deletion app/models/vmdb_metric/purging.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,19 @@ def purge_timer(value, interval)
MiqQueue.put(
:class_name => name,
:method_name => "purge_#{interval}",
:args => [value]
:args => [value],
:msg_timeout => msg_timeout
)
end

def purge_window_size
::Settings.database.metrics_history.purge_window_size
end

def msg_timeout
::Settings.database.metrics_history.queue_timeout.to_i_with_method
end

def purge_count(mode, value, interval)
send("purge_count_by_#{mode}", value, interval)
end
Expand Down
4 changes: 3 additions & 1 deletion config/settings.yml
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@
:keep_hourly_metrics: 6.months
:purge_schedule: "50 * * * *"
:purge_window_size: 10000
:queue_timeout: 20.minutes
:drift_states:
:history:
:keep_drift_states: 6.months
Expand Down Expand Up @@ -895,6 +896,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
Expand Down Expand Up @@ -1167,7 +1169,7 @@
:orchestration_stack_retired_interval: 10.minutes
:performance_collection_interval: 3.minutes
:performance_collection_start_delay: 5.minutes
:performance_realtime_purging_interval: 15.minutes
:performance_realtime_purging_interval: 21.minutes
:performance_realtime_purging_start_delay: 5.minutes
:performance_rollup_purging_interval: 4.hours
:performance_rollup_purging_start_delay: 5.minutes
Expand Down
33 changes: 19 additions & 14 deletions spec/models/metric/purging_spec.rb
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -12,6 +30,7 @@
q.each do |qi|
expect(qi).to have_attributes(
:class_name => described_class.name,
:msg_timeout => 1200
)
end

Expand All @@ -23,22 +42,8 @@
context "with data" do
let(:vm1) { FactoryGirl.create(:vm_vmware) }
let(:vm2) { FactoryGirl.create(:vm_vmware) }
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)

@metrics1 = [
FactoryGirl.create(:metric_rollup_vm_hr, :resource_id => vm1.id, :timestamp => (6.months + 1.days).ago.utc),
FactoryGirl.create(:metric_rollup_vm_hr, :resource_id => vm1.id, :timestamp => (6.months - 1.days).ago.utc)
Expand Down

0 comments on commit 6271921

Please sign in to comment.