Merge "Add num_retries configuration option"
This commit is contained in:
@@ -262,6 +262,9 @@ instance_type = m1.tiny
|
||||
#TCP/IP connection timeout
|
||||
http_socket_timeout = 5
|
||||
|
||||
#Number of retries actions on connection or 5xx error
|
||||
num_retries = 1
|
||||
|
||||
# Status change wait timout
|
||||
build_timeout = 120
|
||||
|
||||
|
||||
@@ -475,6 +475,11 @@ class BotoConfig(BaseConfig):
|
||||
"""boto Http socket timeout"""
|
||||
return self.get("http_socket_timeout", "3")
|
||||
|
||||
@property
|
||||
def num_retries(self):
|
||||
"""boto num_retries on error"""
|
||||
return self.get("num_retries", "1")
|
||||
|
||||
@property
|
||||
def build_timeout(self):
|
||||
"""status change timeout"""
|
||||
|
||||
@@ -36,6 +36,7 @@ class BotoClientBase(object):
|
||||
*args, **kwargs):
|
||||
|
||||
self.connection_timeout = config.boto.http_socket_timeout
|
||||
self.num_retries = config.boto.num_retries
|
||||
self.build_timeout = config.boto.build_timeout
|
||||
# We do not need the "path": "/token" part
|
||||
if auth_url:
|
||||
@@ -63,12 +64,13 @@ class BotoClientBase(object):
|
||||
raise NotFound("Unable to get access and secret keys")
|
||||
return ec2_cred
|
||||
|
||||
def _config_boto_timeout(self, timeout):
|
||||
def _config_boto_timeout(self, timeout, retries):
|
||||
try:
|
||||
boto.config.add_section("Boto")
|
||||
except DuplicateSectionError:
|
||||
pass
|
||||
boto.config.set("Boto", "http_socket_timeout", timeout)
|
||||
boto.config.set("Boto", "num_retries", retries)
|
||||
|
||||
def __getattr__(self, name):
|
||||
"""Automatically creates methods for the allowed methods set"""
|
||||
@@ -86,7 +88,7 @@ class BotoClientBase(object):
|
||||
raise AttributeError(name)
|
||||
|
||||
def get_connection(self):
|
||||
self._config_boto_timeout(self.connection_timeout)
|
||||
self._config_boto_timeout(self.connection_timeout, self.num_retries)
|
||||
if not all((self.connection_data["aws_access_key_id"],
|
||||
self.connection_data["aws_secret_access_key"])):
|
||||
if all(self.ks_cred.itervalues()):
|
||||
|
||||
Reference in New Issue
Block a user