DataSourceEc2: only do dns check in mirror selection
This returns the check for an archive mirror in the DataSourceEc2 to only do so by DNS resolution. The 'rework' branch had made the check wait and timeout on attempts to reach the mirror. This resulted in 120 seconds of waiting before failure. For now, just go back to the old situation of checking by dns.
This commit is contained in:
parent
d4cceb85a0
commit
86d657e66e
|
@ -87,6 +87,7 @@ class DataSourceEc2(sources.DataSource):
|
|||
return self.get_mirror_from_availability_zone()
|
||||
|
||||
def get_mirror_from_availability_zone(self, availability_zone=None):
|
||||
# Return type None indicates there is no cloud specific mirror
|
||||
# Availability is like 'us-west-1b' or 'eu-west-1a'
|
||||
if availability_zone is None:
|
||||
availability_zone = self.get_availability_zone()
|
||||
|
@ -94,26 +95,26 @@ class DataSourceEc2(sources.DataSource):
|
|||
if self.is_vpc():
|
||||
return None
|
||||
|
||||
# Use the distro to get the mirror
|
||||
if not availability_zone:
|
||||
return None
|
||||
|
||||
mirror_tpl = self.distro.get_option('availability_zone_template')
|
||||
if not mirror_tpl:
|
||||
mirror_tpl = self.distro.get_option('package_mirror_ec2_template', None)
|
||||
|
||||
if mirror_tpl is None:
|
||||
return None
|
||||
|
||||
# in EC2, the 'region' is 'us-east-1' if 'zone' is 'us-east-1a'
|
||||
tpl_params = {
|
||||
'zone': availability_zone.strip(),
|
||||
'region': availability_zone[:-1]
|
||||
}
|
||||
mirror_url = mirror_tpl % (tpl_params)
|
||||
|
||||
(max_wait, timeout) = self._get_url_settings()
|
||||
worked = uhelp.wait_for_url([mirror_url], max_wait=max_wait,
|
||||
timeout=timeout, status_cb=LOG.warn)
|
||||
if not worked:
|
||||
return None
|
||||
found = util.search_for_mirror([mirror_url])
|
||||
if found is not None:
|
||||
return mirror_url
|
||||
|
||||
return mirror_url
|
||||
return None
|
||||
|
||||
def _get_url_settings(self):
|
||||
mcfg = self.ds_cfg
|
||||
|
|
|
@ -805,7 +805,10 @@ def is_resolvable_url(url):
|
|||
|
||||
|
||||
def search_for_mirror(candidates):
|
||||
""" Search through a list of mirror urls for one that works """
|
||||
"""
|
||||
Search through a list of mirror urls for one that works
|
||||
This needs to return quickly.
|
||||
"""
|
||||
for cand in candidates:
|
||||
try:
|
||||
if is_resolvable_url(cand):
|
||||
|
|
|
@ -70,5 +70,5 @@ system_info:
|
|||
templates_dir: /etc/cloud/templates/
|
||||
upstart_dir: /etc/init/
|
||||
package_mirror: http://archive.ubuntu.com/ubuntu
|
||||
availability_zone_template: http://%(zone)s.ec2.archive.ubuntu.com/ubuntu/
|
||||
package_mirror_ec2_template: http://%(region)s.ec2.archive.ubuntu.com/ubuntu/
|
||||
ssh_svcname: ssh
|
||||
|
|
Loading…
Reference in New Issue