diff options
author | Adam Leff <adam@leff.co> | 2016-06-28 11:24:23 -0400 |
---|---|---|
committer | Adam Leff <adam@leff.co> | 2016-06-28 16:02:41 -0400 |
commit | 3f6db5dc96b5ecb552a491e77730356e8df2021d (patch) | |
tree | 1ab2389d92d013ac83f7b0919c175f17a9a8eeaf /lib | |
parent | 945f23be7a43d90ae7ed402d05363b3ff0c11bff (diff) | |
download | chef-3f6db5dc96b5ecb552a491e77730356e8df2021d.tar.gz |
Adding node object to run_converge message, include ignore_failure property
Many use cases that involve consuming the run_converge messages and
displaying them to end users include needing additional data about
the node that generated the run_converge message. This change
consolidates the run_converge and node_update message into a single
message making it easier for users to filter run_converge messages
based on attributes and criteria of the node itself.
Additionally, the ignore_failure property on a resource is now
included for each resource in the resource list so end users can
decided whether the failure was a hard failure or a soft failure.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/chef/data_collector.rb | 1 | ||||
-rw-r--r-- | lib/chef/data_collector/messages.rb | 31 | ||||
-rw-r--r-- | lib/chef/data_collector/resource_report.rb | 19 |
3 files changed, 11 insertions, 40 deletions
diff --git a/lib/chef/data_collector.rb b/lib/chef/data_collector.rb index e7ef8d39ec..d307fff2ba 100644 --- a/lib/chef/data_collector.rb +++ b/lib/chef/data_collector.rb @@ -279,7 +279,6 @@ class Chef # we have nothing to report. return unless run_status - send_to_data_collector(Chef::DataCollector::Messages.node_update_message(run_status).to_json) send_to_data_collector( Chef::DataCollector::Messages.run_end_message( run_status: run_status, diff --git a/lib/chef/data_collector/messages.rb b/lib/chef/data_collector/messages.rb index 89bad9f9f9..8c2a84b580 100644 --- a/lib/chef/data_collector/messages.rb +++ b/lib/chef/data_collector/messages.rb @@ -68,6 +68,7 @@ class Chef "id" => run_status.run_id, "message_version" => "1.0.0", "message_type" => "run_converge", + "node" => run_status.node, "node_name" => run_status.node.name, "organization_name" => organization, "resources" => reporter_data[:resources].map(&:report_data), @@ -90,36 +91,6 @@ class Chef message end - - # - # Message payload that is sent to the DataCollector server at the - # end of a Chef run. - # - # @param run_status [Chef::RunStatus] The RunStatus instance for this node/run. - # - # @return [Hash] A hash containing the node object and related metadata. - # - def self.node_update_message(run_status) - { - "entity_name" => run_status.node.name, - "entity_type" => "node", - "entity_uuid" => node_uuid, - "id" => SecureRandom.uuid, - "message_version" => "1.1.0", - "message_type" => "action", - "organization_name" => organization, - "recorded_at" => Time.now.utc.iso8601, - "remote_hostname" => run_status.node["fqdn"], - "requestor_name" => run_status.node.name, - "requestor_type" => "client", - "run_id" => run_status.run_id, - "service_hostname" => chef_server_fqdn(run_status), - "source" => collector_source, - "task" => "update", - "user_agent" => Chef::HTTP::HTTPRequest::DEFAULT_UA, - "data" => run_status.node, - } - end end end end diff --git a/lib/chef/data_collector/resource_report.rb b/lib/chef/data_collector/resource_report.rb index 89b6d26706..e031d4bcb6 100644 --- a/lib/chef/data_collector/resource_report.rb +++ b/lib/chef/data_collector/resource_report.rb @@ -65,15 +65,16 @@ class Chef def to_hash hash = { - "type" => new_resource.resource_name.to_sym, - "name" => new_resource.name.to_s, - "id" => new_resource.identity.to_s, - "after" => new_resource.state_for_resource_reporter, - "before" => current_resource ? current_resource.state_for_resource_reporter : {}, - "duration" => elapsed_time_in_milliseconds.to_s, - "delta" => new_resource.respond_to?(:diff) && potentially_changed? ? new_resource.diff : "", - "result" => action.to_s, - "status" => status, + "type" => new_resource.resource_name.to_sym, + "name" => new_resource.name.to_s, + "id" => new_resource.identity.to_s, + "after" => new_resource.state_for_resource_reporter, + "before" => current_resource ? current_resource.state_for_resource_reporter : {}, + "duration" => elapsed_time_in_milliseconds.to_s, + "delta" => new_resource.respond_to?(:diff) && potentially_changed? ? new_resource.diff : "", + "ignore_failure" => new_resource.ignore_failure, + "result" => action.to_s, + "status" => status, } if new_resource.cookbook_name |