Skip to content

Commit

Permalink
Merge pull request #53 from borod108/bugs/metrics_error_in_logs
Browse files Browse the repository at this point in the history
Fix unhandled exception in metrics collection when missing credentials
  • Loading branch information
oourfali authored Jun 29, 2017
2 parents ff1ccd2 + 32de2aa commit 4c6fc3c
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,13 @@ def perf_release_rhevm
#

def perf_collect_metrics(interval_name, start_time = nil, end_time = nil)
log_header = "[#{interval_name}] for: [#{target.class.name}], [#{target.id}], [#{target.name}]"
target_description = "[#{target.class.name}], [#{target.id}], [#{target.name}]"
unless target.ext_management_system.has_authentication_type?(:metrics)
_log.warn("No C&U credentials defined for: #{target_description} returning empty stats")
return {}, {}
end

log_header = "[#{interval_name}] for: #{target_description}"
start_time ||= Metric::Capture.historical_start_time

begin
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,12 @@
expect(OvirtMetrics).to receive(:host_realtime).with(host.uid_ems, start_time, nil)
host.perf_collect_metrics("realtime")
end

context 'ems has no metrics authentication' do
let(:ems) { FactoryGirl.create(:ems_redhat) }
it 'returns empty results when no credentials are defined' do
expect(host.perf_collect_metrics("realtime")).to eq([{}, {}])
end
end
end
end

0 comments on commit 4c6fc3c

Please sign in to comment.