diff options
author | Serdar Sutay <serdar@opscode.com> | 2014-08-12 12:48:12 -0700 |
---|---|---|
committer | Serdar Sutay <serdar@opscode.com> | 2014-08-12 12:48:12 -0700 |
commit | 1ad7c5938a3eb83200616142d0a0b857d416a300 (patch) | |
tree | cda46252ea6d2a4162f99eb4307be7d89acafab7 | |
parent | d9601d8df71d8b680e4b9e14ed49f14d91813d30 (diff) | |
parent | 182b69e150d9138ef6bb0623e02ea516579399be (diff) | |
download | chef-1ad7c5938a3eb83200616142d0a0b857d416a300.tar.gz |
Merge pull request #1772 from opscode/chef-1765
chef-client should never send negative values for duration to reporting
-rw-r--r-- | CHANGELOG.md | 57 | ||||
-rw-r--r-- | lib/chef/resource.rb | 3 | ||||
-rw-r--r-- | spec/unit/resource_spec.rb | 11 |
3 files changed, 41 insertions, 30 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index cca6d5ee98..c01fd3bbef 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,40 +1,13 @@ # Chef Client Changelog -## Unreleased: +## Unreleased: 12.0.0 -* chef/json_compat now throws its own exceptions not JSON gem exceptions -* Modify action for env raises Chef::Exceptions::Env exception on Windows (Chef Issues 1754) -* Fix a bug in the experimental Policyfile mode that caused errors when - using templates. -* Disable JSON encoding of request body when non-JSON content type is - specified. -* Clean up FileVendor and CookbookUploader internal APIs * [**Vasiliy Tolstov**](https://github.com/vtolstov): Reload systemd service only if it's running, otherwise start. * [**Chris Jerdonek**](https://github.com/cjerdonek): knife diagnostic messages sent to stdout instead of stderr * [**Xabier de Zuazo**](https://github.com/zuazo): Remove the unused StreamingCookbookUploader class (CHEF-4586) - -* log resource now marks itself as supporting why-run -* http_request no longer appends "?message=" query string to GET and HEAD requests -* added shell_out commands directly to the recipe DSL -* cookbook synchronizer deletes old files from cookbooks -* do not clear file cache when override run list is set (CHEF-3684) -* ruby 1.8.7/1.9.1/1.9.2 support is dropped -* set no_lazy_load to true (CHEF-4961) -* set file_stating_uses_destdir config option default to true (CHEF-5040) -* remove dependency on rest-client gem -* Add method shell_out_with_systems_locale to ShellOut. -* Fix knife cookbook site share on windows (CHEF-4994) -* chef-repo rake tasks are deprecated; print relevant information for - each one. -* Fix RPM package version detection (Issue 1554) -* Don't override :default provider map if :default passed as platform (OC-11667). -* Fix SuSE package removal failure (Issue 1732). -* Enable Travis to run Test Kitchen with Kitchen EC2. - - * [**Phil Dibowitz**](https://github.com/jaymzh): 'group' provider on OSX properly uses 'dscl' to determine existing groups * [**Hugo Lopes Tavares**](https://github.com/hltbra): @@ -73,6 +46,34 @@ Add whitespace boundaries to some mount point references in mount provider. + +* chef/json_compat now throws its own exceptions not JSON gem exceptions +* Modify action for env raises Chef::Exceptions::Env exception on Windows (Chef Issues 1754) +* Fix a bug in the experimental Policyfile mode that caused errors when + using templates. +* Disable JSON encoding of request body when non-JSON content type is + specified. +* Clean up FileVendor and CookbookUploader internal APIs +* log resource now marks itself as supporting why-run +* http_request no longer appends "?message=" query string to GET and HEAD requests +* added shell_out commands directly to the recipe DSL +* cookbook synchronizer deletes old files from cookbooks +* do not clear file cache when override run list is set (CHEF-3684) +* ruby 1.8.7/1.9.1/1.9.2 support is dropped +* set no_lazy_load to true (CHEF-4961) +* set file_stating_uses_destdir config option default to true (CHEF-5040) +* remove dependency on rest-client gem +* Add method shell_out_with_systems_locale to ShellOut. +* Fix knife cookbook site share on windows (CHEF-4994) +* chef-repo rake tasks are deprecated; print relevant information for + each one. +* Fix RPM package version detection (Issue 1554) +* Don't override :default provider map if :default passed as platform (OC-11667). +* Fix SuSE package removal failure (Issue 1732). +* Enable Travis to run Test Kitchen with Kitchen EC2. +* Fix a bug in reporting not to post negative duration values. + + ## Last Release: 11.14.2 * [**Jess Mink**](https://github.com/jmink): 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 diff --git a/spec/unit/resource_spec.rb b/spec/unit/resource_spec.rb index dd6d58630f..70941e4e82 100644 --- a/spec/unit/resource_spec.rb +++ b/spec/unit/resource_spec.rb @@ -344,7 +344,7 @@ describe Chef::Resource do expected_keys = [ :allowed_actions, :params, :provider, :updated, :updated_by_last_action, :before, :supports, :noop, :ignore_failure, :name, :source_line, - :action, :retries, :retry_delay, :elapsed_time, + :action, :retries, :retry_delay, :elapsed_time, :guard_interpreter, :sensitive ] (hash.keys - expected_keys).should == [] (expected_keys - hash.keys).should == [] @@ -527,6 +527,13 @@ describe Chef::Resource do snitch_var2.should be_false end + it "reports 0 elapsed time if actual elapsed time is < 0" do + expected = Time.now + Time.stub(:now).and_return(expected, expected - 1) + @resource.run_action(:purr) + @resource.elapsed_time.should == 0 + end + describe "guard_interpreter attribute" do let(:resource) { @resource } @@ -788,7 +795,7 @@ describe Chef::Resource do before(:each) do @resource_file = Chef::Resource::File.new("/nonexistent/CHEF-5098/file", @run_context) @action = :create - end + end def compiled_resource_data(resource, action, err) error_inspector = Chef::Formatters::ErrorInspectors::ResourceFailureInspector.new(resource, action, err) |