summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeremiah Snapp <jeremiah@getchef.com>2014-08-06 14:30:38 -0400
committerSerdar Sutay <serdar@opscode.com>2014-08-12 09:48:11 -0700
commit5ded6f5aaa5998b64665566d6fca85add7cecd15 (patch)
treeeba26899014d20d3004aa58fe15d8dfce20ecdce
parent9ce5259cd0e57aecec337ddbbdac1e6a2683ad2b (diff)
downloadchef-5ded6f5aaa5998b64665566d6fca85add7cecd15.tar.gz
chef-client should never send negative values for duration to reporting; fixes 1765
The duration can be negative if a resource changes the system's time. We should return 0 duration instead to indicate that something unusual happened.
-rw-r--r--lib/chef/resource.rb3
1 files changed, 3 insertions, 0 deletions
diff --git a/lib/chef/resource.rb b/lib/chef/resource.rb
index 6adf937f53..84d6a2fca6 100644
--- a/lib/chef/resource.rb
+++ b/lib/chef/resource.rb
@@ -660,6 +660,9 @@ F
end
ensure
@elapsed_time = Time.now - start_time
+ # Reporting endpoint doesn't accept a negative resource duration so set it to 0.
+ # A negative value can occur when a resource changes the system time backwards
+ @elapsed_time = 0 if @elapsed_time < 0
events.resource_completed(self)
end
end