-
Notifications
You must be signed in to change notification settings - Fork 896
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
Fix queueing of historical metrics collection #14695
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
155ddd6
Fix queueing of historical metrics collection
gtanzillo 8b5bf74
Splitting realtime collection into historical
blomquisg baed845
More splitting realtime and tests
blomquisg 9bf613e
Fix RuboCop - Use `update_attributes` instead of `update_attribute`
gtanzillo 004569f
Handle case where last_perf_capture_on is nil and just queue up a sin…
gtanzillo File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -46,20 +46,31 @@ def perf_capture_queue(interval_name, options = {}) | |
|
||
log_target = "#{self.class.name} name: [#{name}], id: [#{id}]" | ||
|
||
# Determine the items to queue up | ||
# cb is the task used to group cluster realtime metrics | ||
cb = nil | ||
if interval_name == 'historical' | ||
start_time = Metric::Capture.historical_start_time if start_time.nil? | ||
end_time = Time.now.utc if end_time.nil? | ||
end_time ||= 1.day.from_now.utc.beginning_of_day # Ensure no more than one historical collection is queue up in the same day | ||
items = split_capture_intervals(interval_name, start_time, end_time) | ||
else | ||
start_time = last_perf_capture_on unless start_time | ||
end_time = Time.now.utc unless end_time | ||
# if last_perf_capture_on is earlier than 4.hour.ago.beginning_of_day, | ||
# then create *one* realtime capture for start_time = 4.hours.ago.beginning_of_day (no end_time) | ||
# and create historical captures for each day from last_perf_capture_on until 4.hours.ago.beginning_of_day | ||
realtime_cut_off = 4.hours.ago.utc.beginning_of_day | ||
items = | ||
if last_perf_capture_on.nil? | ||
[[interval_name, realtime_cut_off]] | ||
elsif last_perf_capture_on < realtime_cut_off | ||
[[interval_name, realtime_cut_off]] + | ||
split_capture_intervals("historical", last_perf_capture_on, realtime_cut_off) | ||
else | ||
[interval_name] | ||
end | ||
|
||
cb = {:class_name => self.class.name, :instance_id => id, :method_name => :perf_capture_callback, :args => [[task_id]]} if task_id | ||
end | ||
|
||
# Determine what items we should be queuing up | ||
items = [interval_name] | ||
items = split_capture_intervals(interval_name, start_time, end_time) if start_time | ||
|
||
# Queue up the actual items | ||
queue_item = { | ||
:class_name => self.class.name, | ||
|
@@ -78,15 +89,17 @@ def perf_capture_queue(interval_name, options = {}) | |
if msg.nil? | ||
qi[:priority] = priority | ||
qi.delete(:state) | ||
qi[:miq_callback] = cb if cb | ||
if cb && item_interval == "realtime" | ||
qi[:miq_callback] = cb | ||
end | ||
qi | ||
elsif msg.state == "ready" && (task_id || MiqQueue.higher_priority?(priority, msg.priority)) | ||
qi[:priority] = priority | ||
# rerun the job (either with new task or higher priority) | ||
qi.delete(:state) | ||
if task_id | ||
existing_tasks = (((msg.miq_callback || {})[:args] || []).first) || [] | ||
qi[:miq_callback] = cb.merge(:args => [existing_tasks + [task_id]]) | ||
qi[:miq_callback] = cb.merge(:args => [existing_tasks + [task_id]]) if item_interval == "realtime" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If we can get rid of the check on upgrading priority, then it will be easier to go over to Real-time will potentially still need this |
||
end | ||
qi | ||
else | ||
|
@@ -177,6 +190,8 @@ def perf_capture(interval_name, start_time = nil, end_time = nil) | |
|
||
if start_range.nil? | ||
_log.info "#{log_header} Skipping processing for #{log_target} as no metrics were captured." | ||
# Set the last capture on to end_time to prevent forever queueing up the same collection range | ||
update_attributes(:last_perf_capture_on => end_time || Time.now.utc) if interval_name == 'realtime' | ||
else | ||
if expected_start_range && start_range > expected_start_range | ||
_log.warn "#{log_header} For #{log_target}, expected to get data as of [#{expected_start_range}], but got data as of [#{start_range}]." | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't see this before. very nice