summaryrefslogtreecommitdiff
path: root/lib/chef/resource_reporter.rb
diff options
context:
space:
mode:
authorPrajaktaPurohit <prajakta@opscode.com>2014-01-19 18:07:17 -0800
committerPrajakta Purohit <prajakta@opscode.com>2014-02-07 15:31:10 -0800
commita4cdce667a1bc1828eea875bdf3f49af6d96da70 (patch)
treeccf5fb1bf44f0eda5ad0470f0957dd31864c62f0 /lib/chef/resource_reporter.rb
parent29e732d97ec7e28b2111aca9f93edfd1bc257c2d (diff)
downloadchef-a4cdce667a1bc1828eea875bdf3f49af6d96da70.tar.gz
- Adding X-Remote-Request-Id to the set of headers for every request from CCR and
knife that will be sent to erchef - Each knife request has a different X-Remote-Request-Id, where as it remains the same for all requests originating from the same chef-client run. - Adding and fixing tests
Diffstat (limited to 'lib/chef/resource_reporter.rb')
-rw-r--r--lib/chef/resource_reporter.rb11
1 files changed, 7 insertions, 4 deletions
diff --git a/lib/chef/resource_reporter.rb b/lib/chef/resource_reporter.rb
index 04f4ee26de..d191710cb4 100644
--- a/lib/chef/resource_reporter.rb
+++ b/lib/chef/resource_reporter.rb
@@ -107,7 +107,6 @@ class Chef
@pending_update = nil
@status = "success"
@exception = nil
- @run_id = SecureRandom.uuid
@rest_client = rest_client
@error_descriptions = {}
end
@@ -118,7 +117,7 @@ class Chef
if reporting_enabled?
begin
resource_history_url = "reports/nodes/#{node_name}/runs"
- server_response = @rest_client.post_rest(resource_history_url, {:action => :start, :run_id => @run_id,
+ server_response = @rest_client.post_rest(resource_history_url, {:action => :start, :run_id => run_id,
:start_time => start_time.to_s}, headers)
rescue Timeout::Error, Errno::EINVAL, Errno::ECONNRESET, EOFError, Net::HTTPBadResponse, Net::HTTPHeaderSyntaxError, Net::ProtocolError => e
handle_error_starting_run(e, resource_history_url)
@@ -158,6 +157,10 @@ class Chef
@reporting_enabled = false
end
+ def run_id
+ @run_status.run_id
+ end
+
def resource_current_state_loaded(new_resource, action, current_resource)
unless nested_resource?(new_resource)
@pending_update = ResourceReport.new_with_current_state(new_resource, action, current_resource)
@@ -214,8 +217,8 @@ class Chef
def post_reporting_data
if reporting_enabled?
run_data = prepare_run_data
- resource_history_url = "reports/nodes/#{node_name}/runs/#{@run_id}"
- Chef::Log.info("Sending resource update report (run-id: #{@run_id})")
+ resource_history_url = "reports/nodes/#{node_name}/runs/#{run_id}"
+ Chef::Log.info("Sending resource update report (run-id: #{run_id})")
Chef::Log.debug run_data.inspect
compressed_data = encode_gzip(run_data.to_json)
begin