From b60bcdb87f0c99e1f027fdd9fa11f89cc91d0620 Mon Sep 17 00:00:00 2001 From: Paul Donohue Date: Tue, 22 Oct 2024 17:08:13 -0400 Subject: [PATCH] Handle Facter errors as failures --- files/report.rb | 3 +++ manifests/init.pp | 3 +++ spec/classes/init_spec.rb | 1 + templates/puppet.yaml.erb | 1 + 4 files changed, 8 insertions(+) diff --git a/files/report.rb b/files/report.rb index 960a6a4..3402c70 100644 --- a/files/report.rb +++ b/files/report.rb @@ -121,6 +121,9 @@ def metrics_to_hash(report) end # fix for Puppet non-resource errors (i.e. failed catalog fetches before falling back to cache) report_status["failed"] += report.logs.find_all {|l| l.source =~ /Puppet$/ && l.level.to_s == 'err' }.count + if SETTINGS.fetch(:report_facter_errors, true) + report_status["failed"] += report.logs.count {|l| l.source == 'Facter' && l.level.to_s == 'err' } + end return report_status end diff --git a/manifests/init.pp b/manifests/init.pp index e64d789..ddc4634 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -36,6 +36,8 @@ # The timeout to use on HTTP calls in the report processor # @param report_retry_limit # The number of times to retry HTTP calls in the report processor +# @param report_facter_errors +# Whether to exclude facter errors from report metrics # @param puppet_basedir # The directory used to install the report processor to # @param use_client_tls_certs @@ -54,6 +56,7 @@ Boolean $reports = true, Integer[0] $reports_timeout = 60, Integer[0] $report_retry_limit = 1, + Boolean $report_facter_errors = true, Variant[Enum[''], Stdlib::Absolutepath] $ssl_ca = $puppetserver_foreman::params::client_ssl_ca, Variant[Enum[''], Stdlib::Absolutepath] $ssl_cert = $puppetserver_foreman::params::client_ssl_cert, Variant[Enum[''], Stdlib::Absolutepath] $ssl_key = $puppetserver_foreman::params::client_ssl_key, diff --git a/spec/classes/init_spec.rb b/spec/classes/init_spec.rb index 2b1c25f..e6e21e4 100644 --- a/spec/classes/init_spec.rb +++ b/spec/classes/init_spec.rb @@ -129,6 +129,7 @@ ':timeout: 60', ':report_timeout: 60', ':report_retry_limit: 1', + ':report_facter_errors: true', ':threads: null', ]) end diff --git a/templates/puppet.yaml.erb b/templates/puppet.yaml.erb index 6808de8..d852eeb 100644 --- a/templates/puppet.yaml.erb +++ b/templates/puppet.yaml.erb @@ -12,4 +12,5 @@ :timeout: <%= @enc_timeout %> :report_timeout: <%= @reports_timeout %> :report_retry_limit: <%= @report_retry_limit %> +:report_facter_errors: <%= @report_facter_errors %> :threads: null