From 5ded6f5aaa5998b64665566d6fca85add7cecd15 Mon Sep 17 00:00:00 2001 From: Jeremiah Snapp Date: Wed, 6 Aug 2014 14:30:38 -0400 Subject: 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. --- lib/chef/resource.rb | 3 +++ 1 file changed, 3 insertions(+) (limited to 'lib') 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 -- cgit v1.2.1