remove make_call loop, raise exception on failures, leave it up to caller to determine what to do
# Imports within Ruby's standard libraries
require 'openssl'
require 'net/http'
-require 'timeout'
require 'json'
@@ -19,20 +18,9 @@ class InfrastructureManagerClient
# The port that the InfrastructureManager runs on, by default.
SERVER_PORT = 17444
- # A constant that indicates that there should be no timeout on SOAP calls.
- NO_TIMEOUT = 100000
-
# A constant that indicates the number of second to wait.
SMALL_WAIT = 3
- # A constant that callers can use to indicate that SOAP calls should be
- # retried if they fail (e.g., if the connection was refused).
- RETRY_ON_FAIL = true
-
- # A constant that callers can use to indicate that SOAP calls should not
- # be retried if they fail.
- ABORT_ON_FAIL = false
-
# The secret string that is used to authenticate this client with
# InfrastructureManagers. It is initially generated by
# appscale-run-instances and can be found on the machine that ran that tool,
@@ -46,7 +34,6 @@ class InfrastructureManagerClient
# Wrapper to call HTTP method.
def make_call(request, uri)
- loop do
begin
response = Net::HTTP.start(uri.hostname, uri.port) do |http|
http.request(request)
@@ -58,12 +45,19 @@ class InfrastructureManagerClient
raise AppScaleException.new(log_message)
end
return response.body
- rescue Net::ReadTimeout, Errno::ECONNREFUSED, Errno::ETIMEDOUT => error
+ rescue Net::ReadTimeout, Errno::ETIMEDOUT => error
Djinn.log_warn(
- "[IM] Error when calling #{uri.hostname}:#{uri.port}#{uri.path}. Trying " \
- "again. Error: #{error.message}")
- sleep(SMALL_WAIT)
- end
+ "[IM] Timeout when calling #{uri.hostname}:#{uri.port}#{uri.path}." \
+ "Trying again. Error: #{error.message}")
+ raise FailedNodeException.new("Time out calling IaaS on " \
+ "#{@ip}:#{SERVER_PORT}")
+ rescue Errno::ECONNREFUSED => error
+ Djinn.log_warn(
+ "[IM] Connection refused when calling #{uri.hostname}:#{uri.port}" \
+ "#{uri.path}. IaaS Manager may be down? Trying again. Error: " \
+ "#{error.message}")
+ raise FailedNodeException.new("Connection refused calling IaaS on " \
+ "#{@ip}:#{SERVER_PORT}")
end
end
