summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorClaire McQuin <mcquin@users.noreply.github.com>2014-08-07 10:56:46 -0700
committerSerdar Sutay <serdar@opscode.com>2014-08-15 14:53:45 -0700
commite9f303b9f288c03baee9d8b40cca58838ff3c3a4 (patch)
treeec0b14c26ed1cb5709e85d69f273e3c48b64c9b7 /lib
parent8008b6cf07dd2fe9ae1ff83a144af5c3cc0582cd (diff)
downloadchef-e9f303b9f288c03baee9d8b40cca58838ff3c3a4.tar.gz
Merge pull request #1551 from hltbra/fix-resource-reporter-post-resporting-data
Fix ResourceReporter#post_reporting_data http error handling. Fixes #1550
Diffstat (limited to 'lib')
-rw-r--r--lib/chef/resource_reporter.rb14
1 files changed, 7 insertions, 7 deletions
diff --git a/lib/chef/resource_reporter.rb b/lib/chef/resource_reporter.rb
index 47bbd13741..046e4e82c6 100644
--- a/lib/chef/resource_reporter.rb
+++ b/lib/chef/resource_reporter.rb
@@ -231,17 +231,17 @@ class Chef
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)
+ Chef::Log.debug("Sending compressed run data...")
+ # Since we're posting compressed data we can not directly call post_rest which expects JSON
+ reporting_url = @rest_client.create_url(resource_history_url)
begin
- Chef::Log.debug("Sending compressed run data...")
- # Since we're posting compressed data we can not directly call post_rest which expects JSON
- reporting_url = @rest_client.create_url(resource_history_url)
@rest_client.raw_http_request(:POST, reporting_url, headers({'Content-Encoding' => 'gzip'}), compressed_data)
- rescue Net::HTTPServerException => e
- if e.response.code.to_s == "400"
+ rescue StandardError => e
+ if e.respond_to? :response
Chef::FileCache.store("failed-reporting-data.json", Chef::JSONCompat.to_json_pretty(run_data), 0640)
- Chef::Log.error("Failed to post reporting data to server (HTTP 400), saving to #{Chef::FileCache.load("failed-reporting-data.json", false)}")
+ Chef::Log.error("Failed to post reporting data to server (HTTP #{e.response.code}), saving to #{Chef::FileCache.load("failed-reporting-data.json", false)}")
else
- Chef::Log.error("Failed to post reporting data to server (HTTP #{e.response.code.to_s})")
+ Chef::Log.error("Failed to post reporting data to server (#{e})")
end
end
else