Project

General

Profile

« Previous | Next » 

Revision 1c039da8

Added by Ohad Levy almost 13 years ago

  • ID 1c039da84cbbad8b07cd9b1f6e9f15bc7720e3bf

fixes #930 - Skipped resources should not put systems in 'error' state

View differences:

app/controllers/hosts_controller.rb
end
def errors
params[:search]="last_report > \"#{SETTINGS[:puppet_interval] + 5} minutes ago\" and (status.failed > 0 or status.failed_restarts > 0 or status.skipped > 0)"
params[:search]="last_report > \"#{SETTINGS[:puppet_interval] + 5} minutes ago\" and (status.failed > 0 or status.failed_restarts > 0)"
index "Hosts with errors"
end
app/models/host.rb
}
named_scope :with_error, { :conditions => "(puppet_status > 0) and
((puppet_status >> #{Report::BIT_NUM*Report::METRIC.index("failed")} & #{Report::MAX}) != 0) or
((puppet_status >> #{Report::BIT_NUM*Report::METRIC.index("failed_restarts")} & #{Report::MAX}) != 0) or
((puppet_status >> #{Report::BIT_NUM*Report::METRIC.index("skipped")} & #{Report::MAX}) != 0)"
((puppet_status >> #{Report::BIT_NUM*Report::METRIC.index("failed_restarts")} & #{Report::MAX}) != 0)"
}
app/views/host_mailer/_active_hosts.text.html.erb
<tr>
<%= render 'link_to_host', :host => host %>
<% params[:metrics].each do |m,v| -%>
<% if m =~ /failed|skipped|failed_restart/ and v > 0 -%>
<% if m =~ /failed|failed_restart/ and v > 0 -%>
<td style="color:red;font-weight:bold;border:1px solid #FF9933;border-collapse:collapse;padding:4px;background-color:#FFFFFF;">
<% else -%>
<td style="border:1px solid #FF9933;border-collapse:collapse;padding:4px;background-color:#FFFFFF;">
app/views/hosts/_metrics.html.erb
<% report_summary.each do |name, value| -%>
<tr class="<%= cycle("even", "odd") -%>">
<td style="width: 240px;"> <%= name %> </td>
<% style = (name =~ /failed|skipped|failed_restart/ and value > 0) ? "color:red;font-weight:bold" : ""-%>
<% style = (name =~ /failed|failed_restart/ and value > 0) ? "color:red;font-weight:bold" : ""-%>
<td style="<%= style %>"> <%= value %> </td>
</tr>
<% end -%>
test/unit/report_test.rb
assert @r.error?
end
test "it should not be an error if there are only skips" do
@r.status={"applied" => 92, "restarted" => 300, "failed" => 0, "failed_restarts" => 0, "skipped" => 3}
assert !@r.error?
end
test "it should false on error? if there were no errors" do
@r.status={"applied" => 92, "restarted" => 300, "failed" => 0, "failed_restarts" => 0, "skipped" => 0}
assert @r.error? == false
assert !@r.error?
end
test "with named scope should return our report with applied resources" do

Also available in: Unified diff