22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
|
# File 'lib/garcon/chef/provider/recovery.rb', line 22
def run_action_rescued(action = nil)
run_action_unrescued(action)
Chef::Log.debug "Finished running #{new_resource.resource_name}" \
"[#{new_resource.name}] -- no exception"
rescue Exception => e
Chef::Log.info "#{new_resource.resource_name}[#{new_resource.name}] " \
"failed with: #{e.inspect}"
if new_resource.instance_variable_defined?('@recovery_handlers'.to_sym)
new_resource.recovery_handlers.each do |recovery_struct|
if recovery_struct.options[:retries] > 0 &&
(recovery_struct.exceptions.any? { |klass| e.is_a?(klass) } ||
recovery_struct.exceptions.empty?)
recovery_struct.options[:retries] -= 1
instance_exec(new_resource, &recovery_struct.block)
run_action_rescued(action)
return
end
end
end
raise exception
end
|