diff options
author | Steven Murawski <steven.murawski@gmail.com> | 2016-02-18 14:58:32 -0600 |
---|---|---|
committer | Steven Murawski <steven.murawski@gmail.com> | 2016-05-23 13:32:49 -0500 |
commit | e24b8e2cd67aef572fde184e8b07d48333184b29 (patch) | |
tree | 2b1f6507104149182791436be30561be3be1aef2 /lib/chef/platform | |
parent | e4bca443a3ddca6381275a1a252de04f5e4883c4 (diff) | |
download | chef-e24b8e2cd67aef572fde184e8b07d48333184b29.tar.gz |
* define exit codes
* exit code functional specs
* audit exit codes
* reboot now/reboot failed/reboot pending exit codes
* Deal with forked and unforked process and get the right exit code
* Reboot Now should really be reboot scheduled
* pass exception rather than exit code
* updated with sigint and sigterm
* support legacy fatal!("", 2) behavior
* fixup all fatal! and exit! calls
Diffstat (limited to 'lib/chef/platform')
-rw-r--r-- | lib/chef/platform/rebooter.rb | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/lib/chef/platform/rebooter.rb b/lib/chef/platform/rebooter.rb index c678b60dd1..74c8b2da1f 100644 --- a/lib/chef/platform/rebooter.rb +++ b/lib/chef/platform/rebooter.rb @@ -19,6 +19,7 @@ require "chef/dsl/reboot_pending" require "chef/log" require "chef/platform" +require "chef/application/exit_code" class Chef class Platform @@ -27,6 +28,8 @@ class Chef class << self + include Chef::DSL::RebootPending + def reboot!(node) reboot_info = node.run_context.reboot_info @@ -38,8 +41,16 @@ class Chef "shutdown -r +#{reboot_info[:delay_mins]} \"#{reboot_info[:reason]}\"" end - Chef::Log.warn "Rebooting server at a recipe's request. Details: #{reboot_info.inspect}" - shell_out!(cmd) + msg = "Rebooting server at a recipe's request. Details: #{reboot_info.inspect}" + begin + Chef::Log.warn msg + shell_out!(cmd) + rescue Mixlib::ShellOut::ShellCommandFailed => e + raise Chef::Exceptions::RebootFailed.new(e.message) + end + + raise Chef::Exceptions::Reboot.new(msg) if Chef::Application::ExitCode.enforce_rfc_062_exit_codes? + Chef::Application::ExitCode.notify_reboot_exit_code_deprecation end # this is a wrapper function so Chef::Client only needs a single line of code. |