summaryrefslogtreecommitdiff
path: root/cloudinit/sources/DataSourceOpenStack.py
diff options
context:
space:
mode:
authorScott Moser <smoser@ubuntu.com>2014-02-13 12:13:42 -0500
committerScott Moser <smoser@ubuntu.com>2014-02-13 12:13:42 -0500
commit87d0fa867f27f101e93006ba8dc8a395098e8df1 (patch)
tree39a81a1f9b5074fbbb681b738e13ae4c1a8238f8 /cloudinit/sources/DataSourceOpenStack.py
parentf82e9552145ff468763727d7e5a53f56dc9f5b20 (diff)
downloadvyos-cloud-init-87d0fa867f27f101e93006ba8dc8a395098e8df1.tar.gz
vyos-cloud-init-87d0fa867f27f101e93006ba8dc8a395098e8df1.zip
wait less for the metadata service (by default)
Waiting around for a metadata service in a given datasource means that if its not there all the subsequent datasources have to wait, and boot is slowed down. As it is right now, EC2 is the only one that has the right to wait. In the past, we had to wait around for the EC2 metadata service. I really do not want to extend that courtesy to other cloud platforms. A network based metadata service should be up as soon as networking is up.
Diffstat (limited to 'cloudinit/sources/DataSourceOpenStack.py')
-rw-r--r--cloudinit/sources/DataSourceOpenStack.py28
1 files changed, 13 insertions, 15 deletions
diff --git a/cloudinit/sources/DataSourceOpenStack.py b/cloudinit/sources/DataSourceOpenStack.py
index 69807798..7fafa3f7 100644
--- a/cloudinit/sources/DataSourceOpenStack.py
+++ b/cloudinit/sources/DataSourceOpenStack.py
@@ -45,6 +45,8 @@ class DataSourceOpenStack(openstack.SourceMixin, sources.DataSource):
self.version = None
self.files = {}
self.ec2_metadata = None
+ if not self.ds_cfg:
+ self.ds_cfg = {}
def __str__(self):
root = sources.DataSource.__str__(self)
@@ -54,27 +56,25 @@ class DataSourceOpenStack(openstack.SourceMixin, sources.DataSource):
def _get_url_settings(self):
# TODO(harlowja): this is shared with ec2 datasource, we should just
# move it to a shared location instead...
- ds_cfg = self.ds_cfg
- if not ds_cfg:
- ds_cfg = {}
- max_wait = 120
+ # Note: the defaults here are different though.
+
+ # max_wait < 0 indicates do not wait
+ max_wait = -1
+ timeout = 10
+
try:
- max_wait = int(ds_cfg.get("max_wait", max_wait))
+ max_wait = int(self.ds_cfg.get("max_wait", max_wait))
except Exception:
util.logexc(LOG, "Failed to get max wait. using %s", max_wait)
- timeout = 50
try:
- timeout = max(0, int(ds_cfg.get("timeout", timeout)))
+ timeout = max(0, int(self.ds_cfg.get("timeout", timeout)))
except Exception:
util.logexc(LOG, "Failed to get timeout, using %s", timeout)
return (max_wait, timeout)
def wait_for_metadata_service(self):
- ds_cfg = self.ds_cfg
- if not ds_cfg:
- ds_cfg = {}
- urls = ds_cfg.get("metadata_urls", [DEF_MD_URL])
+ urls = self.ds_cfg.get("metadata_urls", [DEF_MD_URL])
filtered = [x for x in urls if util.is_resolvable_url(x)]
if set(filtered) != set(urls):
LOG.debug("Removed the following from metadata urls: %s",
@@ -95,8 +95,6 @@ class DataSourceOpenStack(openstack.SourceMixin, sources.DataSource):
url2base[md_url] = url
(max_wait, timeout) = self._get_url_settings()
- if max_wait <= 0:
- return False
start_time = time.time()
avail_url = url_helper.wait_for_url(urls=md_urls, max_wait=max_wait,
timeout=timeout,
@@ -104,8 +102,8 @@ class DataSourceOpenStack(openstack.SourceMixin, sources.DataSource):
if avail_url:
LOG.debug("Using metadata source: '%s'", url2base[avail_url])
else:
- LOG.critical("Giving up on md from %s after %s seconds",
- md_urls, int(time.time() - start_time))
+ LOG.debug("Giving up on OpenStack md from %s after %s seconds",
+ md_urls, int(time.time() - start_time))
self.metadata_address = url2base.get(avail_url)
return bool(avail_url)