ec2-fetch-credentials do not work in jaunty instance being run on Eucalyptus

Bug #432773 reported by Etienne Goyer
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
cloud-init (Ubuntu)
Invalid
Undecided
Unassigned
ec2-init (Ubuntu)
New
Undecided
Unassigned

Bug Description

Binary package hint: ec2-init

It seems like the command ec2-fetch-credentials do not work when being run in a jaunty instance (ec-init version 0.3.3ubuntu12), itself running on eucalyptus 1.5~bzr266-0ubuntu2 on jaunty. I believe, although I am not sure, that the output of the meta-data server is not parsed properly by ec2-fetch-credentials. Here is the output in question:

ubuntu@ubuntu:~$ wget http://169.254.169.254/2008-02-01/meta-data/public-keys/
--2009-09-18 17:55:29-- http://169.254.169.254/2008-02-01/meta-data/public-keys/
Connecting to 169.254.169.254:80... connected.
   [...snip wget output...]
2009-09-18 17:55:29 (1.98 MB/s) - `index.html' saved [19]

ubuntu@ubuntu:~$ cat index.html
0=warthogs-dba-key
ubuntu@ubuntu:~$ ec2-fetch-credentials
Traceback (most recent call last):
  File "/usr/sbin/ec2-fetch-credentials", line 80, in <module>
    keys = get_ssh_keys()
  File "/usr/sbin/ec2-fetch-credentials", line 39, in get_ssh_keys
    return [urllib.urlopen('%s/public-keys/%d/openssh-key' % (base_url, int(keyid))).read().rstrip() for keyid in keyids]
ValueError: invalid literal for int() with base 10: ''

Revision history for this message
Etienne Goyer (etienne-goyer-outlands) wrote :

After investigation (thanks Marc!), it seems like Eucalyptus add a trailing newline to the output of http://169.254.169.254/2008-02-01/meta-data/public-keys/. That confuse ec2-fetch-credentials; adding a check for empty newline in get_ssh_keys() actually fix the bug, such as:

def get_ssh_keys():
    base_url = 'http://169.254.169.254/%s/meta-data' % api_ver
    data = urllib.urlopen('%s/public-keys/' % base_url).read()
    keyids = [line.split('=')[0] for line in data.split('\n') if line] <-- *** That is where to check for empty line ***
    return [urllib.urlopen('%s/public-keys/%d/openssh-key' % (base_url, int(keyid))).read().rstrip() for keyid in keyids]

Scott Moser (smoser)
Changed in cloud-init (Ubuntu):
status: New → Invalid
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.