diff options
author | Scott Moser <smoser@ubuntu.com> | 2011-07-19 23:17:27 -0400 |
---|---|---|
committer | Scott Moser <smoser@ubuntu.com> | 2011-07-19 23:17:27 -0400 |
commit | be623b70dbc7c591f14baa9314105e78bbe0f63f (patch) | |
tree | a77e2fb8fd8e8216490fee36fd9d6924a6559e2d /cloudinit | |
parent | 6d25c040ee566f6ef85352d7b52eb5947230f78a (diff) | |
download | vyos-cloud-init-be623b70dbc7c591f14baa9314105e78bbe0f63f.tar.gz vyos-cloud-init-be623b70dbc7c591f14baa9314105e78bbe0f63f.zip |
increase timeout on read_seed when a seedfrom was explicitly given
In the case where a seedfrom value was given on the command line or in the
config file, we were timing out in 2 seconds on the connection. That timeout
was put in place to support "probing" for sources, but seedfrom is explictly
given.
So, in that case, do a urllib.open without a timeout value. Looking at source
code, default timeout is 'socket._GLOBAL_DEFAULT_TIMEOUT', but rather than
importing that and using it, I will call without a timeout value.
LP: #812646
Diffstat (limited to 'cloudinit')
-rw-r--r-- | cloudinit/DataSourceNoCloud.py | 2 | ||||
-rw-r--r-- | cloudinit/util.py | 8 |
2 files changed, 7 insertions, 3 deletions
diff --git a/cloudinit/DataSourceNoCloud.py b/cloudinit/DataSourceNoCloud.py index 3d429bc5..e9e9c152 100644 --- a/cloudinit/DataSourceNoCloud.py +++ b/cloudinit/DataSourceNoCloud.py @@ -86,7 +86,7 @@ class DataSourceNoCloud(DataSource.DataSource): # this could throw errors, but the user told us to do it # so if errors are raised, let them raise - (md_seed,ud) = util.read_seeded(seedfrom) + (md_seed,ud) = util.read_seeded(seedfrom, timeout=None) log.debug("using seeded cache data from %s" % seedfrom) # values in the command line override those from the seed diff --git a/cloudinit/util.py b/cloudinit/util.py index ec37f2f7..b3842afa 100644 --- a/cloudinit/util.py +++ b/cloudinit/util.py @@ -189,8 +189,12 @@ def read_seeded(base="", ext="", timeout=2): md_url = "%s%s%s" % (base, "meta-data", ext) try: - md_resp = urllib2.urlopen(urllib2.Request(md_url), timeout=timeout) - ud_resp = urllib2.urlopen(urllib2.Request(ud_url), timeout=timeout) + if timeout == None: + md_resp = urllib2.urlopen(urllib2.Request(md_url)) + ud_resp = urllib2.urlopen(urllib2.Request(ud_url)) + else: + md_resp = urllib2.urlopen(urllib2.Request(md_url), timeout=timeout) + ud_resp = urllib2.urlopen(urllib2.Request(ud_url), timeout=timeout) md_str = md_resp.read() ud = ud_resp.read() |