=== modified file 'cloud-init-cfg.py' --- cloud-init-cfg.py 2010-02-17 09:40:30 +0000 +++ cloud-init-cfg.py 2010-04-20 15:28:51 +0000 @@ -53,4 +53,6 @@ sys.exit(0) if __name__ == '__main__': + sys.stderr.write("======= %s called with %s ======\n" % ("cloud-init-cfg", sys.argv)) + sys.stderr.flush() main() === modified file 'cloudinit/DataSourceEc2.py' --- cloudinit/DataSourceEc2.py 2010-02-17 09:40:30 +0000 +++ cloudinit/DataSourceEc2.py 2010-04-20 15:45:34 +0000 @@ -20,6 +20,7 @@ import socket import urllib2 import time +import sys import boto_utils class DataSourceEc2(DataSource.DataSource): @@ -100,20 +101,41 @@ except: return 'http://archive.ubuntu.com/ubuntu/' - def wait_for_metadata_service(self, sleeps = 10): + + def wait_for_metadata_service(self, sleeps = 20): sleeptime = 1 + address = '169.254.169.254' + port = 80 + connected = False for x in range(sleeps): s = socket.socket() + s.settimeout(2) try: - address = '169.254.169.254' - port = 80 s.connect((address,port)) s.close() - return True + connected = True + break except socket.error, e: - print "sleeping %s" % sleeptime + sys.stderr.write("connect to %s:%s failed, sleeping %s [%s/%s]\n" % (address, port, sleeptime, x+1,sleeps)) time.sleep(sleeptime) - #timeout = timeout * 2 + + if not connected: return False + + for x in range(sleeps): + url="http://%s/%s/meta-data/instance-id" % (address,self.api_ver) + reason = "" + try: + req = urllib2.Request(url) + resp = urllib2.urlopen(req) + if resp.read() != "": return True + reason = "empty data [%s]" % resp.getcode() + except urllib2.HTTPError, e: + reason = "http error [%s]" % e.code + except urllib2.URLError, e: + reason = "url error [%s]" % e.code + + sys.stderr.write("waiting for md at %s [%s/%s]: %s\n" % (url,x+1,sleeps, reason)) + time.sleep(sleeptime) return False def get_public_ssh_keys(self): === modified file 'debian/changelog' --- debian/changelog 2010-03-26 05:03:19 +0000 +++ debian/changelog 2010-04-20 15:29:39 +0000 @@ -1,3 +1,10 @@ +cloud-init (0.5.10-0ubuntu2~debug0) lucid; urgency=low + + * add a upstart job to turn on debug, and better metadata service + debugging + + -- Scott Moser Tue, 20 Apr 2010 11:16:49 -0400 + cloud-init (0.5.10-0ubuntu1) lucid; urgency=low * New upstream release. === modified file 'debian/cloud-init.postinst' --- debian/cloud-init.postinst 2010-02-05 15:48:21 +0000 +++ debian/cloud-init.postinst 2010-04-20 15:27:59 +0000 @@ -8,4 +8,11 @@ /etc/init/ureadahead.conf.disabled --add /etc/init/ureadahead.conf fi +cat 1>&2 < /debug-init' + ************** +EOF + #DEBHELPER# === added file 'upstart/debug-info.conf' --- upstart/debug-info.conf 1970-01-01 00:00:00 +0000 +++ upstart/debug-info.conf 2010-04-20 15:26:03 +0000 @@ -0,0 +1,14 @@ +# turn on debugging for init +# This code does nothing by default. To turn on debugging you have to: +# The reason it is turned off is because of bug 566793 +# - echo "info" > /debug-init +# "info" could be one of debug, info, message, warn, error, fatal (initctl(8)) +description "debug me" +start on startup +task +script +[ -f /debug-init ] || exit 0 +level=info +read level < /debug-init || exit 0 +exec initctl log-priority ${level} +end script