summaryrefslogtreecommitdiff
path: root/lib/chef/http.rb
diff options
context:
space:
mode:
authorLamont Granquist <lamont@scriptkiddie.org>2014-08-23 21:36:23 -0700
committerLamont Granquist <lamont@scriptkiddie.org>2014-08-23 21:36:23 -0700
commit920d190cd817da50dcf87c3046b7c5f3bdcae7f9 (patch)
treec8dded9ea7f02dfbdc195955b167422cf0c72c78 /lib/chef/http.rb
parentfb58236637095e22f25ed17143e435f4a58d7d6c (diff)
downloadchef-920d190cd817da50dcf87c3046b7c5f3bdcae7f9.tar.gz
Revert "add retries in additional cases"
Pushed straight to master again, I need to stop coding... This reverts commit fb58236637095e22f25ed17143e435f4a58d7d6c.
Diffstat (limited to 'lib/chef/http.rb')
-rw-r--r--lib/chef/http.rb24
1 files changed, 5 insertions, 19 deletions
diff --git a/lib/chef/http.rb b/lib/chef/http.rb
index bf2316113e..abc47f636e 100644
--- a/lib/chef/http.rb
+++ b/lib/chef/http.rb
@@ -62,6 +62,7 @@ class Chef
end
+
def self.middlewares
@middlewares ||= []
end
@@ -281,34 +282,18 @@ class Chef
end
end
+
# Wraps an HTTP request with retry logic.
# === Arguments
# url:: URL of the request, used for error messages
def retrying_http_errors(url)
http_attempts = 0
begin
- loop do
- http_attempts += 1
-
- response, request, return_value = yield
-
- if response.kind_of?(Net::HTTPServerError)
- if http_retry_count >= http_attempts
- Chef::Log.error("Error connecting to #{url} - #{response.code}, retry #{http_attempts}/#{http_retry_count}")
- sleep(http_retry_delay)
- redo
- end
- end
+ http_attempts += 1
- return [response, request, return_value]
- end
+ yield
rescue SocketError, Errno::ETIMEDOUT => e
- if http_retry_count - http_attempts + 1 > 0
- Chef::Log.error("Error connecting to #{url} - #{e.message}, retry #{http_attempts}/#{http_retry_count}")
- sleep(http_retry_delay)
- retry
- end
e.message.replace "Error connecting to #{url} - #{e.message}"
raise e
rescue Errno::ECONNREFUSED
@@ -395,6 +380,7 @@ class Chef
raise
end
+
public
############################################################################