-
Notifications
You must be signed in to change notification settings - Fork 453
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
Add support for Critical Plugins #1064
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall 👍 but tweaks.
lib/ohai/plugins/linux/filesystem.rb
Outdated
@@ -92,6 +92,7 @@ def generate_mountpoint_view(fs) | |||
end | |||
|
|||
collect_data(:linux) do | |||
fail "i iz failing" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oops :)
lib/ohai/system.rb
Outdated
@@ -107,6 +108,21 @@ def run_plugins(safe = false, attribute_filter = nil) | |||
Ohai::Log.error("Encountered error while running plugins: #{e.inspect}") | |||
raise | |||
end | |||
critical_failed = [] | |||
@runner.failed_plugins.each do |failed| | |||
if Ohai::Config.ohai[:critical_plugins].include?(failed) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can use a set intersection to do this, critical_failed = Ohai::Config.ohai[:critical_plugins] & @runner.failed_plugins
.
1449e61
to
4eb6f21
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tests are good 😄
lib/ohai/system.rb
Outdated
Ohai::Log.error(msg) | ||
exit | ||
else | ||
fail "#{msg}. Failing Chef run." |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should have a specific exception class
lib/ohai/plugins/linux/filesystem.rb
Outdated
@@ -92,6 +92,7 @@ def generate_mountpoint_view(fs) | |||
end | |||
|
|||
collect_data(:linux) do | |||
fail "i iz failing" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let's remember to remove this before merging 😄
I like this feature. Would be worth thinking about adding some plugins to the list by default for Chef 14 |
440168c
to
34e6a65
Compare
OK, review comments, now failing with a unique exception, and a test. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🚀
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
34e6a65
to
a05740d
Compare
Updated message for @tas50 |
come on Travis, you can do it! |
a05740d
to
1b139f3
Compare
Travis seems better, so updating this PR with a RELEASE_NOTES.md update to kick travis. |
This adds a new Ohai configuration `critical_plugins` which will cause Ohai to exit (or `fail` if inside of Chef) if the plugins in the list do not run successfully. This feature only supports Ohai 7-style named plugins, not the ancient Ohai 6-style stuff. Tests to follow, but: ``` $ cat /home/phild/ohai.rb ohai.critical_plugins << :Filesystem $ ./bin/ohai -c /home/phild/ohai.rb [2017-10-03T13:43:14-07:00] INFO: The plugin path /etc/chef/ohai/plugins does not exist. Skipping... [2017-10-03T13:43:14-07:00] ERROR: The following plugins marked as critical failed: [:Filesystem] ``` And when I run Chef: ``` [2017-10-03T13:44:11-07:00] FATAL: RuntimeError: The following plugins marked as critical failed: [:Filesystem2]. Failing Chef run. ``` This fixes chef#879. Signed-off-by: Phil Dibowitz <phil@ipom.com>
1b139f3
to
66794cd
Compare
Fixing lint |
Description
This adds a new Ohai configuration
critical_plugins
which will causeOhai to exit (or
fail
if inside of Chef) if the plugins in the list donot run successfully.
This feature only supports Ohai 7-style named plugins, not the ancient
Ohai 6-style stuff.
Tests to follow, but:
And when I run Chef:
Issues Resolved
This fixes #879.
Check List