Skip to content
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

Increase timeout for metric purging #15312

Merged
merged 3 commits into from
Jun 14, 2017
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
2 changes: 2 additions & 0 deletions 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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we also need to increase performance_realtime_purging_interval to avoid overlapping in scheduler ?

:host_overhead:
:memory: 2.01.percent
:cpu: 0.15.percent
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