as lp:494185 points out, need better logic for selecting ec2 mirror Over all, it takes a much better "hit" to select a ec2 mirror. This should greatly reduce the chance for false positives. The chance for error is then: a.) availability zone names change form (ie, no longer '[a-z]') b.) there are images in a new region before a mirror is up, but the dns entry already exists c.) availability zone empty or failed I think its reasonably good, the only thing that concerns me is the possibility of getaddrinfo hanging. === modified file 'debian/changelog' --- debian/changelog 2009-10-26 16:18:06 +0000 +++ debian/changelog 2009-12-11 20:13:11 +0000 @@ -1,3 +1,9 @@ +ec2-init (0.4.999-0ubuntu8) karmic; urgency=low + + * fix mirror selection for us-west-1 (LP: #494185) + + -- Scott Moser Fri, 11 Dec 2009 15:12:19 -0500 + ec2-init (0.4.999-0ubuntu7) karmic; urgency=low * work around differences in eucalyptus ephemeral mounts (LP: #458850) === modified file 'debian/rules' --- debian/rules 2009-09-25 14:17:17 +0000 +++ debian/rules 2009-12-11 20:16:50 +0000 @@ -3,6 +3,7 @@ DEB_PYTHON_SYSTEM=pycentral include /usr/share/cdbs/1/class/python-distutils.mk include /usr/share/cdbs/1/rules/debhelper.mk +include /usr/share/cdbs/1/rules/simple-patchsys.mk DEB_DH_INSTALLINIT_ARGS=-o DEB_UPDATE_RCD_PARAMS:= start 15 2 3 4 5 . stop 20 1 . === modified file 'ec2init/__init__.py' --- ec2init/__init__.py 2009-08-26 01:23:52 +0000 +++ ec2init/__init__.py 2009-12-11 20:12:11 +0000 @@ -88,12 +88,13 @@ return hostname def get_mirror_from_availability_zone(self, availability_zone): - if availability_zone.startswith("us"): - return 'http://us.ec2.archive.ubuntu.com/ubuntu/' - elif availability_zone.startswith("eu"): - return 'http://eu.ec2.archive.ubuntu.com/ubuntu/' - - return 'http://archive.ubuntu.com/ubuntu/' + # availability is like 'us-west-1b' or 'eu-west-1a' + try: + host="%s.ec2.archive.ubuntu.com" % availability_zone[:-1] + socket.getaddrinfo(host, None, 0, socket.SOCK_STREAM) + return 'http://%s/ubuntu/' % host + except: + return 'http://archive.ubuntu.com/ubuntu/' def wait_for_metadata_service(self): timeout = 2