summaryrefslogtreecommitdiff
path: root/lib/chef
diff options
context:
space:
mode:
authorKrzysztof Wilczynski <krzysztof.wilczynski@linux.com>2014-10-19 11:03:39 +0100
committerKrzysztof Wilczynski <krzysztof.wilczynski@linux.com>2014-10-19 11:03:39 +0100
commitb266ca180c803887c2d41342840279c90ba6e931 (patch)
treeb88005e061c592231eda088e7d95c11fb7804c54 /lib/chef
parent9b3e925188a41bbea954429ac81ffdf65e936eda (diff)
downloadchef-b266ca180c803887c2d41342840279c90ba6e931.tar.gz
Fix value of retries shown in the error report.
Fixes #2258. Signed-off-by: Krzysztof Wilczynski <krzysztof.wilczynski@linux.com>
Diffstat (limited to 'lib/chef')
-rw-r--r--lib/chef/resource.rb13
1 files changed, 9 insertions, 4 deletions
diff --git a/lib/chef/resource.rb b/lib/chef/resource.rb
index 0b8fb2cb12..e92ea28c69 100644
--- a/lib/chef/resource.rb
+++ b/lib/chef/resource.rb
@@ -652,6 +652,11 @@ F
# on accident
updated_by_last_action(false)
+ # Don't modify @retries directly and keep it intact, so that the
+ # recipe_snippet from ResourceFailureInspector can print the value
+ # that was set in the resource block initially.
+ remaining_retries = retries
+
begin
return if should_skip?(action)
provider_for_action(action).run_action
@@ -659,10 +664,10 @@ F
if ignore_failure
Chef::Log.error("#{custom_exception_message(e)}; ignore_failure is set, continuing")
events.resource_failed(self, action, e)
- elsif retries > 0
- events.resource_failed_retriable(self, action, retries, e)
- @retries -= 1
- Chef::Log.info("Retrying execution of #{self}, #{retries} attempt(s) left")
+ elsif remaining_retries > 0
+ events.resource_failed_retriable(self, action, remaining_retries, e)
+ remaining_retries -= 1
+ Chef::Log.info("Retrying execution of #{self}, #{remaining_retries} attempt(s) left")
sleep retry_delay
retry
else