-
Notifications
You must be signed in to change notification settings - Fork 900
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
[WIP] Cap & U - ems centric cleanup #16099
Conversation
app/models/metric/capture.rb
Outdated
@@ -1,4 +1,5 @@ | |||
module Metric::Capture | |||
class Metric | |||
class Capture |
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.
This so you didn't have to indent the whole rest of the file?
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.
yea, I could do class Metric::Capture
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.
deleted
app/models/metric/capture.rb
Outdated
@@ -38,6 +39,12 @@ def self.alert_capture_threshold(target) | |||
::Settings.performance.capture_threshold_with_alerts.default) | |||
end | |||
|
|||
attr_accessor :ems, :interval_name | |||
def initialize(ems = nil, interval_name = "realtime") |
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.
Is a nil ems a valid default here? Looks like it is required further down (at least for ems.zone and maybe Metric::Targets.all_capture_targets(ems)
...not sure what that does with a nil arg yet)
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.
this object is not valid without an ems
But I feel we should always be able to create objects without args for things like specs
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.
fixed
@agrare wants this in |
981452f
to
62431a8
Compare
app/models/metric/capture.rb
Outdated
_log.info("Queueing performance capture...Complete") | ||
def self.perf_collect_all_metrics(ems, interval_name = "realtime", start_time = nil, end_time = nil, options = nil) | ||
ems = ExtManagementSystem.find(ems) unless ems.kind_of?(ExtManagementSystem) | ||
klass = ems.class::MetricsCapture rescue ManageIQ::Providers::BaseManager::MetricsCapture |
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 don't think we need to worry about this, if an EMS doesn't have a MetricsCapture
we will just blowup later in just_perf_capture
when calling perf_collect_metrics
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.
was thinking this gave us compatibility for all providers while we rolled out new code
Since this is going into older branch, thought we'd go for minimal change to each of those repos
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.
fixed
52574b7
to
2f9e4af
Compare
start_time ||= ems.last_metrics_success_date | ||
# For hourly on the first capture, we don't want to get all of the | ||
# historical data, so we shorten the query | ||
start_time ||= 4.hours.ago.utc if interval_name == 'hourly' |
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.
We should probably move 4.hours.ago.utc
as the "realtime cutoff" to a constant since we use it here too
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.
fixed
So this isn't using each target's |
@Fryguy can you take a look? |
This pull request is not mergeable. Please rebase and repush. |
2f9e4af
to
13a83a4
Compare
13a83a4
to
54c8809
Compare
54c8809
to
9babbae
Compare
app/models/metric/capture.rb
Outdated
# called by ui | ||
# run a perf capture zone for a zone or ems | ||
def self.perf_capture_gap_queue(start_time, end_time, zone = nil) | ||
emses = if zone.kind_of?(ExtManagementSystem) |
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.
Can we refactor this method's signature? The way this param zone
can be an ems
is against intuition.
app/models/metric/capture.rb
Outdated
emses = if zone.kind_of?(ExtManagementSystem) | ||
zone | ||
else | ||
zone = Zone.find(zone) if zone && !zone.kind_of?(Zone) |
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.
Does this Zone.find
take in any thing and return the zone that the thing is in?
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.
it takes integers or strings - typically from the queue
3eb8d47
to
c128c36
Compare
spec/models/metric_spec.rb
Outdated
@@ -62,111 +53,12 @@ | |||
} | |||
end | |||
|
|||
it "should queue up enabled targets" do | |||
expect(MiqQueue.group(:class_name, :method_name).count).to eq(expected_queue_items) |
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.
This let
block defining this now deleted expected_queue_items
should be removed as well
spec/models/metric_spec.rb
Outdated
@@ -34,15 +34,6 @@ | |||
end | |||
|
|||
context "executing capture_targets" do | |||
it "should find enabled targets" do | |||
targets = Metric::Targets.capture_targets | |||
assert_infra_targets_enabled targets, %w(ManageIQ::Providers::Vmware::InfraManager::Vm ManageIQ::Providers::Vmware::InfraManager::Host ManageIQ::Providers::Vmware::InfraManager::Host ManageIQ::Providers::Vmware::InfraManager::Vm ManageIQ::Providers::Vmware::InfraManager::Host Storage) |
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.
This assert_infra_targets_enabled
seems obsoleted as well.
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.
Thanks - I'll delete Metric::Targets.capture_targets
as well
:class_name => "Metric::Capture", | ||
:method_name => "perf_collect_all_metrics", | ||
:args => [ems.id, "realtime", nil, nil, :exclude_storage => true], | ||
:zone => ems.zone_name |
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.
👍 so this should be able to catch the zone_name
vs zone.id
issue
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.
provided that the test was written correctly in the first place :( - thanks for the catch
end | ||
|
||
# legacy messages on the queue | ||
# went away in 4.6 |
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.
this #went away in 4.6
still true?
we need this for 4.6 coz 4.5 could have left behind queued item for this deprecated method.
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.
Well, the callers have all gone away.
I put this note in there to let people know that it is just around for legacy messages.
Are you thinking the scheduler should be paired down and still generate this message?
So all the intelligence will be in this process instead of the Scheduler::Runner
?
Alternatively, we could delete the contents of this method since there will only ever be one message in the queue and the contents will just get picked up a few minutes later when the scheduler submits it again.
app/models/metric/capture.rb
Outdated
perf_collect_all_metrics_queue(zone.ext_management_systems, "realtime") | ||
end | ||
|
||
def self.perf_collect_all_metrics_queue(ems, interval_name = "realtime", start_time = nil, end_time = nil, options = {}) |
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.
question: why not make the param ems
as emses
and we have no need for the Array.wrap
?
(Is this ruby style to make the caller happier?)
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 had not realized that everything coming in is an array.
My initial intent was for us to queue a single metrics collect.
Sad to see the Array.wrap
go, but think you are right - making edit
spec/models/metric/capture_spec.rb
Outdated
it "triggers better capture" do | ||
EvmSpecHelper.local_miq_server.zone | ||
ems # default zone | ||
ems2 # other zone |
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.
and ems3
as well
c128c36
to
26c10fe
Compare
872c419
to
c58df51
Compare
This pull request is not mergeable. Please rebase and repush. |
c58df51
to
a65edb1
Compare
e09afa4
to
1cde354
Compare
This pull request is not mergeable. Please rebase and repush. |
TODO: move from capture to metrics_capture.rb THEN refactor
b1d6402
to
fc76af2
Compare
Some comments on commits kbrock/manageiq@45d685c~...fc76af2 spec/models/miq_vim_broker_worker_spec.rb
|
Checked commits kbrock/manageiq@45d685c~...fc76af2 with ruby 2.3.3, rubocop 0.52.0, haml-lint 0.20.0, and yamllint 1.10.0 app/models/manageiq/providers/base_manager/metrics_capture.rb
app/models/vim_performance_state.rb
|
This pull request is not mergeable. Please rebase and repush. |
This pull request has been automatically closed because it has not been updated for at least 6 months. Feel free to reopen this pull request if these changes are still valid. Thank you for all your contributions! |
Relevant PRs:
capture_targets
perf_capture
into multiple methods #16262 split upperf_capture
VimConnectMixin#connect
cleanupSeparate has_required_role from should_start_worker #16505 reduction ofconnect
Overview
Currently
perf_capture_timer
,perf_capture
, andperf_process
are not working so well together. They create a large number of objects and a large number of queue entries. They also rely uponMiqQueue#put_or_update
which is problematic going to a real queue implementation.The goal is to reorganize the code to more closely map to how providers best communicate metrics and our bottlenecks.
Before
Good: Collection can be done in parallel. (The bottleneck is persisting, not collecting)
Bad: This floods the queue and causes a number of issues for our users. This causes multiple requests for collecting the same objects.
After
metric_capture.rb
and can be extended.metric_capture.rb
to allow for extensibility.perf_process
.Good: able to extend the collection. Already seen big benefits for VMware.
Bad: collection is not able to run in parallel (as said before, it is not a bottleneck)
Notes
storage.rb
overrode all ofperf_capture
work. Since it does not communicate with the provider/ems I left it intact and just offloaded to the processor.