summaryrefslogtreecommitdiff
path: root/lib/chef/resource_reporter.rb
diff options
context:
space:
mode:
authorjamesc <james@opscode.com>2013-04-24 20:07:54 -0700
committerBryan McLellan <btm@opscode.com>2013-06-18 08:58:18 -0700
commit0e0339863da133aaf862ae0d503918d44bcf2055 (patch)
treec0c9fd472e596fa083b1f0cb769d837732a03d33 /lib/chef/resource_reporter.rb
parent41187a430ee3702af913413d0a7554faba362870 (diff)
downloadchef-0e0339863da133aaf862ae0d503918d44bcf2055.tar.gz
[OC-6939] Use start_time/end_time from chef-client
Set start_time/end_time in reporting start/end messages only post exceptions if we've got the node setup
Diffstat (limited to 'lib/chef/resource_reporter.rb')
-rw-r--r--lib/chef/resource_reporter.rb24
1 files changed, 21 insertions, 3 deletions
diff --git a/lib/chef/resource_reporter.rb b/lib/chef/resource_reporter.rb
index ca7718b661..af9af65812 100644
--- a/lib/chef/resource_reporter.rb
+++ b/lib/chef/resource_reporter.rb
@@ -115,10 +115,19 @@ class Chef
def node_load_completed(node, expanded_run_list_with_versions, config)
@node = node
+ end
+
+ def start_time
+ @run_status.start_time
+ end
+
+ def run_started(run_status)
+ @run_status = run_status
if reporting_enabled?
begin
- resource_history_url = "reports/nodes/#{node.name}/runs"
- server_response = @rest_client.post_rest(resource_history_url, {:action => :begin, :run_id => @run_id}, headers)
+ resource_history_url = "reports/nodes/#{@node.name}/runs"
+ server_response = @rest_client.post_rest(resource_history_url, {:action => :begin, :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_beginning_run(e, resource_history_url)
end
@@ -203,7 +212,11 @@ class Chef
def run_failed(exception)
@exception = exception
@status = "failure"
- post_reporting_data
+ # If we haven't had the node setup yet, there's not much we can do
+ # in terms of reporting
+ if @node
+ post_reporting_data
+ end
end
def post_reporting_data
@@ -231,6 +244,10 @@ class Chef
end
end
+ def end_time
+ @run_status.end_time
+ end
+
def prepare_run_data
run_data = {}
run_data["action"] = "end"
@@ -241,6 +258,7 @@ class Chef
run_data["run_list"] = @node.run_list.to_json
run_data["total_res_count"] = @total_res_count.to_s
run_data["data"] = {}
+ run_data["end_time"] = end_time.to_s
if exception
exception_data = {}