diff options
author | Phil Dibowitz <phil@ipom.com> | 2017-10-09 20:06:36 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-10-09 20:06:36 -0700 |
commit | c855e3a81d8235a6228b7b9484af2142b7033327 (patch) | |
tree | c7776216f1a0f4abfac8cc04ef3869684e231cd0 | |
parent | c2869b01147182ce6155e2fbb434b6d45a0dbf0c (diff) | |
download | chef-c855e3a81d8235a6228b7b9484af2142b7033327.tar.gz |
Support new CriticalOhaiPlugins (backport #6486 to chef-12) (#6487)
We should not stack-trace, we should exit with a clean error
Signed-off-by: Phil Dibowitz <phil@ipom.com>
-rw-r--r-- | lib/chef/client.rb | 3 | ||||
-rw-r--r-- | spec/unit/client_spec.rb | 11 |
2 files changed, 14 insertions, 0 deletions
diff --git a/lib/chef/client.rb b/lib/chef/client.rb index 82abd34ff1..8514941d47 100644 --- a/lib/chef/client.rb +++ b/lib/chef/client.rb @@ -605,6 +605,9 @@ class Chef filter = Chef::Config[:minimal_ohai] ? %w{fqdn machinename hostname platform platform_version os os_version} : nil ohai.all_plugins(filter) events.ohai_completed(node) + rescue Ohai::Exceptions::CriticalPluginFailure => e + Chef::Log.error("Critical Ohai plugins failed: #{e.message}") + exit(false) end # diff --git a/spec/unit/client_spec.rb b/spec/unit/client_spec.rb index ba71b3b6a4..8a67f24f5a 100644 --- a/spec/unit/client_spec.rb +++ b/spec/unit/client_spec.rb @@ -44,6 +44,17 @@ describe Chef::Client do end end + context "when Ohai tells us to fail" do + it "fails" do + ohai_system = Ohai::System.new + module Ohai::Exceptions + class CriticalPluginFailure < Error; end + end + expect(ohai_system).to receive(:all_plugins) { raise Ohai::Exceptions::CriticalPluginFailure } + expect { client.run_ohai }.to raise_error(SystemExit) + end + end + describe "authentication protocol selection" do context "when FIPS is disabled" do before do |