summaryrefslogtreecommitdiff
path: root/cloudinit/sources/DataSourceEc2.py
diff options
context:
space:
mode:
authorJoshua Harlow <harlowja@gmail.com>2014-02-01 12:03:32 -0800
committerJoshua Harlow <harlowja@gmail.com>2014-02-01 12:03:32 -0800
commitc8bcf80d4153512450efa72b5ac2d1644a7904bd (patch)
treeb1020dba9316a065bfe45b4cfc27d846e95d71f6 /cloudinit/sources/DataSourceEc2.py
parent3cfe9b3d8958b1a4e450d5ff31d805c424945027 (diff)
downloadvyos-cloud-init-c8bcf80d4153512450efa72b5ac2d1644a7904bd.tar.gz
vyos-cloud-init-c8bcf80d4153512450efa72b5ac2d1644a7904bd.zip
Fix incorrect return
get_url_settings should return a pair of max wait and timeout and not false, fix this bug by checking the max_wait <= 0 in the calling function and returning correctly from there instead.
Diffstat (limited to 'cloudinit/sources/DataSourceEc2.py')
-rw-r--r--cloudinit/sources/DataSourceEc2.py7
1 files changed, 3 insertions, 4 deletions
diff --git a/cloudinit/sources/DataSourceEc2.py b/cloudinit/sources/DataSourceEc2.py
index f010e640..1b20ecf3 100644
--- a/cloudinit/sources/DataSourceEc2.py
+++ b/cloudinit/sources/DataSourceEc2.py
@@ -92,12 +92,9 @@ class DataSourceEc2(sources.DataSource):
except Exception:
util.logexc(LOG, "Failed to get max wait. using %s", max_wait)
- if max_wait == 0:
- return False
-
timeout = 50
try:
- timeout = int(mcfg.get("timeout", timeout))
+ timeout = max(0, int(mcfg.get("timeout", timeout)))
except Exception:
util.logexc(LOG, "Failed to get timeout, using %s", timeout)
@@ -109,6 +106,8 @@ class DataSourceEc2(sources.DataSource):
mcfg = {}
(max_wait, timeout) = self._get_url_settings()
+ if max_wait <= 0:
+ return False
# Remove addresses from the list that wont resolve.
mdurls = mcfg.get("metadata_urls", DEF_MD_URLS)