diff options
author | Thom May <thom@may.lt> | 2016-11-22 11:33:43 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-11-22 11:33:43 +0000 |
commit | e0d1d9aaa50dda6db33dc78d9d6faff11401b809 (patch) | |
tree | 0b10e125470da65553729d763464749666d99330 /lib/chef | |
parent | 6da8d357001b976131e575ce131ac0e04f32e51a (diff) | |
parent | 091df73931ecff79927ab9b55c0f284024c6a58e (diff) | |
download | chef-e0d1d9aaa50dda6db33dc78d9d6faff11401b809.tar.gz |
Merge pull request #5571 from chef/adamleff/fix-data-collector
Ensure Data Collector resource report exists before updating
Diffstat (limited to 'lib/chef')
-rw-r--r-- | lib/chef/data_collector.rb | 25 |
1 files changed, 16 insertions, 9 deletions
diff --git a/lib/chef/data_collector.rb b/lib/chef/data_collector.rb index 102dfbdf64..0e676145eb 100644 --- a/lib/chef/data_collector.rb +++ b/lib/chef/data_collector.rb @@ -174,12 +174,13 @@ class Chef # resource, and we only care about tracking top-level resources. def resource_current_state_loaded(new_resource, action, current_resource) return if nested_resource?(new_resource) - update_current_resource_report(create_resource_report(new_resource, action, current_resource)) + initialize_resource_report_if_needed(new_resource, action, current_resource) end # see EventDispatch::Base#resource_up_to_date # Mark our ResourceReport status accordingly def resource_up_to_date(new_resource, action) + initialize_resource_report_if_needed(new_resource, action) current_resource_report.up_to_date unless nested_resource?(new_resource) end @@ -190,15 +191,15 @@ class Chef def resource_skipped(new_resource, action, conditional) return if nested_resource?(new_resource) - resource_report = create_resource_report(new_resource, action) - resource_report.skipped(conditional) - update_current_resource_report(resource_report) + initialize_resource_report_if_needed(new_resource, action) + current_resource_report.skipped(conditional) end # see EventDispatch::Base#resource_updated # Flag the current ResourceReport instance as updated (as long as it's # a top-level resource). def resource_updated(new_resource, action) + initialize_resource_report_if_needed(new_resource, action) current_resource_report.updated unless nested_resource?(new_resource) end @@ -207,6 +208,7 @@ class Chef # long as it's a top-level resource, and update the run error text # with the proper Formatter. def resource_failed(new_resource, action, exception) + initialize_resource_report_if_needed(new_resource, action) current_resource_report.failed(exception) unless nested_resource?(new_resource) update_error_description( Formatters::ErrorMapper.resource_failed( @@ -224,7 +226,7 @@ class Chef if current_resource_report && !nested_resource?(new_resource) current_resource_report.finish add_resource_report(current_resource_report) - update_current_resource_report(nil) + clear_current_resource_report end end @@ -402,10 +404,6 @@ class Chef @run_status = run_status end - def update_current_resource_report(resource_report) - @current_resource_report = resource_report - end - def update_error_description(discription_hash) @error_descriptions = discription_hash end @@ -414,6 +412,11 @@ class Chef @deprecations << { message: message, url: url, location: location } end + def initialize_resource_report_if_needed(new_resource, action, current_resource = nil) + return unless current_resource_report.nil? + @current_resource_report = create_resource_report(new_resource, action, current_resource) + end + def create_resource_report(new_resource, action, current_resource = nil) Chef::DataCollector::ResourceReport.new( new_resource, @@ -422,6 +425,10 @@ class Chef ) end + def clear_current_resource_report + @current_resource_report = nil + end + def detect_unprocessed_resources # create a Set containing all resource+action combinations from # the Resource Collection |