Skip to content
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

Fixes #27075 - fact names check #267

Merged
merged 1 commit into from
Nov 21, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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