[Bug 845155] [NEW] instance launched without key has incorrect metadata

Scott Moser smoser at canonical.com
Thu Sep 8 21:17:19 UTC 2011


Public bug reported:

Currently on openstack, if you did something like this:

$ cat my.userdata
#cloud-config
ssh_authorized_keys:
 - ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEA3I7VUf2l5gSn5uavROsc5HRDpZdQueUq5ozemNSj8T7enqKHOEaFoU2VoPgGEWC9RyzSQVeyD6s7APMcE82EtmW4skVEgEGSbDc1pvxzxtchBj78hJP6Cf5TCMFSXw+Fz5rF1dR23QDbN1mkHs7adr8GW4kSWqU7Q7NDwfIrJJtO7Hi42GyXtvEONHbiRPOe8stqUly7MvUoN+5kfjBM8Qqpfl2+FNhTYWpMfYdPUnE7u536WqzFmsaqJctz3gBxH9Ex7dFtrxR4qiqEr9Qtlu3xGn7Bw07/+i1D+ey3ONkZLN+LQ714cgj8fRS4Hj29SCmXp5Kt5/82cD/VN3NtHw== smoser at brickies

runcmd:
 - [ sudo, -Hu, ubuntu, ssh-import-id, smoser ]

$ euca-run-instances --user-data-file my.userdata

you'd see a message to the console that says:
   2011-09-08 20:55:52,779 - cc_ssh.py[WARNING]: applying credentials failed!

because i also inserted the key via ssh-import-id i could get to the
instanc,e, then the cloud-init lgo shows:

2011-09-08 20:55:52,778 - util.py[DEBUG]: Traceback (most recent call last):
  File "/usr/lib/python2.7/dist-packages/cloudinit/CloudConfig/cc_ssh.py", line 73, in handle
    keys = cloud.get_public_ssh_keys()
  File "/usr/lib/python2.7/dist-packages/cloudinit/__init__.py", line 437, in get_public_ssh_keys
    return(self.datasource.get_public_ssh_keys())
  File "/usr/lib/python2.7/dist-packages/cloudinit/DataSource.py", line 68, in get_public_ssh_keys
    for keyname, klist in self.metadata['public-keys'].items():
AttributeError: 'str' object has no attribute 'items'

2011-09-08 20:55:52,779 - cc_ssh.py[WARNING]: applying credentials
failed!


The issue is that if no key is given, nova's metadata service will show an entry with an empty value.  EC2's will not show the entry.

ie:
## nova with no key
$ wget http://169.254.169.254/2009-04-04/meta-data/ -O - -q | grep key 
public-keys
$ wget http://169.254.169.254/2009-04-04/meta-data/public-keys -O - -q ; echo

$ wget http://169.254.169.254/2009-04-04/meta-data/ -O - -q | grep key 
public-keys/
$ wget http://169.254.169.254/2009-04-04/meta-data/public-keys -O - -q ; echo
0=mykey

## ec2 with no key:

## nova with a key
$ wget http://169.254.169.254/2009-04-04/meta-data/ -O - -q | grep key 

^ there is no 'public-keys' entry listed.


This could be fixed in any number of ways.
cloud-init could be more forgiving (and probably should), but the right place to fix it is in nova, otherwise to support this in Ubuntu images we'll have to SRU it to all releases.

** Affects: cloud-init
     Importance: Undecided
         Status: New

** Affects: nova
     Importance: Undecided
         Status: New

** Affects: nova (Ubuntu)
     Importance: Undecided
         Status: New

** Affects: nova (Ubuntu Oneiric)
     Importance: Undecided
         Status: New

** Also affects: nova (Ubuntu)
   Importance: Undecided
       Status: New

** Also affects: cloud-init
   Importance: Undecided
       Status: New

** Changed in: nova (Ubuntu)
    Milestone: None => ubuntu-11.10-beta-2

** Also affects: nova (Ubuntu Oneiric)
   Importance: Undecided
       Status: New

-- 
You received this bug notification because you are a member of Ubuntu
Server Team, which is subscribed to nova in Ubuntu.
https://bugs.launchpad.net/bugs/845155

Title:
  instance launched without key has incorrect metadata

To manage notifications about this bug go to:
https://bugs.launchpad.net/cloud-init/+bug/845155/+subscriptions



More information about the Ubuntu-server-bugs mailing list