Skip to content

Commit

Permalink
Change system notify to warning function
Browse files Browse the repository at this point in the history
Prior to this commit, the system manifest produced a notify event at
warning level if sysstat was unmanaged and uninstalled.  This caused
issues in idempotency testing, so this commit changes it to a WARN entry
in the server logs that does not produce an event.
  • Loading branch information
m0dular committed Jul 16, 2021
1 parent 1d9b1f2 commit 1056b3d
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 8 deletions.
8 changes: 3 additions & 5 deletions manifests/system.pp
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,9 @@
contain puppet_metrics_collector::system::cpu
contain puppet_metrics_collector::system::memory
contain puppet_metrics_collector::system::processes
} else {
notify { 'sysstat_missing_warning':
message => 'System collection disabled. Set `puppet_metrics_collector::system::manage_sysstat: true` to enable system metrics',
loglevel => warning,
}
}
else {
warning('System collection disabled. Set `puppet_metrics_collector::system::manage_sysstat: true` to enable system metrics')
}

if $facts['virtual'] == 'vmware' {
Expand Down
3 changes: 0 additions & 3 deletions spec/classes/puppet_metrics_collector_system_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
let(:pre_condition) { 'package{"sysstat": }' }
let(:facts) { { puppet_metrics_collector: { have_sysstat: true, have_systemd: true } } }

it { is_expected.not_to contain_notify('sysstat_missing_warning') }
it { is_expected.to contain_class('puppet_metrics_collector::system::cpu') }
it { is_expected.to contain_class('puppet_metrics_collector::system::memory') }
it { is_expected.to contain_class('puppet_metrics_collector::system::processes') }
Expand All @@ -21,15 +20,13 @@
let(:params) { { manage_sysstat: true } }
let(:facts) { { puppet_metrics_collector: { have_sysstat: false, have_systemd: true } } }

it { is_expected.not_to contain_notify('sysstat_missing_warning') }
it { is_expected.to contain_package('sysstat') }
it { is_expected.to contain_class('puppet_metrics_collector::system::cpu') }
it { is_expected.to contain_class('puppet_metrics_collector::system::memory') }
it { is_expected.to contain_class('puppet_metrics_collector::system::processes') }
end

context 'not installed and not managed' do
it { is_expected.to contain_notify('sysstat_missing_warning') }
it { is_expected.not_to contain_package('sysstat') }
it { is_expected.not_to contain_class('puppet_metrics_collector::system::cpu') }
it { is_expected.not_to contain_class('puppet_metrics_collector::system::memory') }
Expand Down

0 comments on commit 1056b3d

Please sign in to comment.