diff options
author | Stephan Renatus <srenatus@chef.io> | 2017-03-23 13:53:03 +0100 |
---|---|---|
committer | Stephan Renatus <srenatus@chef.io> | 2017-03-27 10:15:35 +0200 |
commit | 5b8cbe0d41762efcd8b3fba12aba4a689eca8fa7 (patch) | |
tree | 0dbe9a4f393a8dcea94cd08348de4226b06b2def /lib/chef/resource.rb | |
parent | 4a7d8849d14905a842fcec42322b30929f2ec995 (diff) | |
download | chef-5b8cbe0d41762efcd8b3fba12aba4a689eca8fa7.tar.gz |
Don't `rescue Exception` for retriable resources
Without this, sending an interrupt signal (hitting Ctrl+C) during a
chef-client run that is currently executing a resources that has
`retries` set will not interrupt the run, although the interrupt handler
set up in Chef::Application calls Process.exit, which raises SystemExit.
If the retryable resource is shelling out, the spawned process also gets
the INT signal and will stop -- however, the chef-run would go on,
merely noticing that the resource has failed and theres X-1 retries
left.
It is imaginable that users depend on some (whacky) Ruby script in a
retriable resource that raises SystemExit, and they want this to _not_
stop the chef-run. So it's up for debate if we just want to merge this
or make it configurable.
In general, I'd like Ctrl+C to _stop my chef-run_, but this expectation
could also be misled.
When adapting tests to this change, it became apparent that for some
reason the runner_spec.rb test didn't behave as expected. I've thus made
those tests a little stricter by replacing some allows by expects.
Signed-off-by: Stephan Renatus <srenatus@chef.io>
Diffstat (limited to 'lib/chef/resource.rb')
-rw-r--r-- | lib/chef/resource.rb | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/lib/chef/resource.rb b/lib/chef/resource.rb index b0e3a372e8..f0d816cd89 100644 --- a/lib/chef/resource.rb +++ b/lib/chef/resource.rb @@ -589,7 +589,7 @@ class Chef begin return if should_skip?(action) provider_for_action(action).run_action - rescue Exception => e + rescue StandardError => e if ignore_failure Chef::Log.error("#{custom_exception_message(e)}; ignore_failure is set, continuing") events.resource_failed(self, action, e) |