make DataSourceEc2 configurable (timeout, retries), lower default retries
This lowers the default retries from 100 to 30 (1050 seconds to 105 seconds)
This commit is contained in:
parent
fe7010cc1a
commit
a5ed6dc10f
@ -80,7 +80,25 @@ class DataSourceEc2(DataSource.DataSource):
|
||||
return fallback
|
||||
|
||||
|
||||
def wait_for_metadata_service(self, sleeps = 100):
|
||||
def wait_for_metadata_service(self, sleeps = None):
|
||||
mcfg = self.ds_cfg
|
||||
if sleeps is None:
|
||||
sleeps = 30
|
||||
try:
|
||||
sleeps = int(mcfg.get("retries",sleeps))
|
||||
except Exception as e:
|
||||
util.logexc(log)
|
||||
log.warn("Failed to get number of sleeps, using %s" % sleeps)
|
||||
|
||||
if sleeps == 0: return False
|
||||
|
||||
timeout=2
|
||||
try:
|
||||
timeout = int(mcfg.get("timeout",timeout))
|
||||
except Exception as e:
|
||||
util.logexc(log)
|
||||
log.warn("Failed to get timeout, using %s" % timeout)
|
||||
|
||||
sleeptime = 1
|
||||
address = '169.254.169.254'
|
||||
starttime = time.time()
|
||||
@ -93,7 +111,7 @@ class DataSourceEc2(DataSource.DataSource):
|
||||
reason = ""
|
||||
try:
|
||||
req = urllib2.Request(url)
|
||||
resp = urllib2.urlopen(req, timeout=2)
|
||||
resp = urllib2.urlopen(req, timeout=timeout)
|
||||
if resp.read() != "": return True
|
||||
reason = "empty data [%s]" % resp.getcode()
|
||||
except urllib2.HTTPError as e:
|
||||
|
10
doc/examples/cloud-config-datasources.txt
Normal file
10
doc/examples/cloud-config-datasources.txt
Normal file
@ -0,0 +1,10 @@
|
||||
# Documentation on data sources configuration options
|
||||
datasource:
|
||||
# Ec2
|
||||
Ec2:
|
||||
# timeout: the timeout value for attempt at metadata service
|
||||
timeout : 2
|
||||
# the number of tries that should be attempted at the metadata service
|
||||
# after each try, a sleep of int(try_number/5)+1 is done
|
||||
# default sleep is 30
|
||||
retries : 30
|
Loading…
x
Reference in New Issue
Block a user