diff options
author | Phil Dibowitz <phil@ipom.com> | 2014-03-18 15:41:36 -0700 |
---|---|---|
committer | Phil Dibowitz <phil@ipom.com> | 2014-03-31 16:06:34 -0700 |
commit | 586df54abfadd3c3cc830d784d5e793fa7bf55e3 (patch) | |
tree | 8def1d8dbff3574665de0d33b6dec631936920a5 | |
parent | a42865a514a35c4309d01e286ecb7d40c67baef3 (diff) | |
download | chef-586df54abfadd3c3cc830d784d5e793fa7bf55e3.tar.gz |
[10-stable] Don't trap TERM if not in daemon mode
The whole point if this magic is meaningless if we're not in daemon
mode.
-rw-r--r-- | CHANGELOG.md | 1 | ||||
-rw-r--r-- | CONTRIBUTIONS.md | 1 | ||||
-rw-r--r-- | RELEASE_NOTES.md | 2 | ||||
-rw-r--r-- | chef/lib/chef/application/client.rb | 11 | ||||
-rw-r--r-- | chef/spec/unit/application/client_spec.rb | 3 |
5 files changed, 12 insertions, 6 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index e90b4506de..4d02e71bbb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ * Service Provider for MacOSX now supports `enable` and `disable` * Chef now gracefully handles corrupted cache files. +* SIGTERM will once-more kill a non-daemonized chef-client (CHEF-5172) ## Last Release: 10.30.4 (02/18/2014) diff --git a/CONTRIBUTIONS.md b/CONTRIBUTIONS.md index d0b917eef7..ade732cbe9 100644 --- a/CONTRIBUTIONS.md +++ b/CONTRIBUTIONS.md @@ -8,3 +8,4 @@ Example Contribution: * **jaymzh**: Service Provider for MacOSX now supports `enable` and `disable` * **jaymzh**: Chef now gracefully handles corrupted cache files. +* **jaymzh**: SIGTERM will once-more kill a non-daemonized chef-client (CHEF-5172) diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md index 7e770d7dfe..870392fc16 100644 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -9,6 +9,6 @@ Details about the thing that changed that needs to get included in the Release N # Chef Client 10.x Release Notes: * Service Provider for MacOSX now supports `enable` and `disable` - +* SIGTERM will now terminate non-daemon mode Chef runs (CHEF-5172) # Chef Client 10.x Breaking Changes: diff --git a/chef/lib/chef/application/client.rb b/chef/lib/chef/application/client.rb index 901a2d79ab..f491111480 100644 --- a/chef/lib/chef/application/client.rb +++ b/chef/lib/chef/application/client.rb @@ -256,10 +256,13 @@ class Chef::Application::Client < Chef::Application SELF_PIPE[1].putc('.') # wakeup master process from select end - trap("TERM") do - Chef::Log.info("SIGTERM received, exiting gracefully") - @exit_gracefully = true - SELF_PIPE[1].putc('.') + # see CHEF-5172 + if Chef::Config[:daemonize] || Chef::Config[:interval] + trap("TERM") do + Chef::Log.info("SIGTERM received, exiting gracefully") + @exit_gracefully = true + SELF_PIPE[1].putc('.') + end end end diff --git a/chef/spec/unit/application/client_spec.rb b/chef/spec/unit/application/client_spec.rb index 6f1f1c4b22..479f4bd49e 100644 --- a/chef/spec/unit/application/client_spec.rb +++ b/chef/spec/unit/application/client_spec.rb @@ -137,11 +137,12 @@ end describe Chef::Application::Client, "run_application", :unix_only do before do - Chef::Config[:daemonize] = false + Chef::Config[:daemonize] = true Chef::Config[:interval] = 10 @pipe = IO.pipe @app = Chef::Application::Client.new + Chef::Daemon.stub!(:daemonize).and_return(true) @app.stub(:run_chef_client) do @pipe[1].puts 'started' sleep 1 |