Skip to content

Commit

Permalink
Fixes #27075 - fact names check
Browse files Browse the repository at this point in the history
  • Loading branch information
lzap committed Nov 21, 2019
1 parent 8c4e8e1 commit e5a6bc2
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 1 deletion.
32 changes: 32 additions & 0 deletions definitions/checks/foreman/facts_names.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
module Checks
module Foreman
class FactsNames < ForemanMaintain::Check
metadata do
label :foreman_fact_names
tags :default
confine do
feature(:foreman_database)
end
description 'Check number of fact names in database'
end

def run
max = 10_000
sql = <<-SQL
select fact_values.host_id, count(fact_values.id) from fact_values
group by fact_values.host_id order by count desc limit 1
SQL
result = feature(:foreman_database).query(sql).first
if result
host_id = result['host_id']
count = result['count'].to_i
assert(count < max,
"Host (ID #{host_id}) has #{count} fact values which is more than #{max}.\n" \
'This can cause slow fact processing.',
:warn => true,
:next_steps => [Procedures::KnowledgeBaseArticle.new(:doc => 'many_fact_values')])
end
end
end
end
end
3 changes: 2 additions & 1 deletion definitions/procedures/knowledge_base_article.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ def kcs_documents
{
'fix_cpdb_validate_failure' => 'https://access.redhat.com/solutions/3362821',
'fix_db_migrate_failure_on_duplicate_roles' => 'https://access.redhat.com/solutions/3998941',
'upgrade_puppet_guide_for_sat63' => 'https://access.redhat.com/documentation/en-us/red_hat_satellite/6.3/html/upgrading_and_updating_red_hat_satellite/upgrading_puppet-1'
'upgrade_puppet_guide_for_sat63' => 'https://access.redhat.com/documentation/en-us/red_hat_satellite/6.3/html/upgrading_and_updating_red_hat_satellite/upgrading_puppet-1',
'many_fact_values' => 'https://access.redhat.com/solutions/4163891'
}
end
end

0 comments on commit e5a6bc2

Please sign in to comment.