[Bug 845155] Re: instance launched without key has incorrect metadata

James Falcon 845155 at bugs.launchpad.net
Tue May 9 17:46:22 UTC 2023


Tracked in Github Issues as https://github.com/canonical/cloud-
init/issues/2201

** Bug watch added: github.com/canonical/cloud-init/issues #2201
   https://github.com/canonical/cloud-init/issues/2201

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

Title:
  instance launched without key has incorrect metadata

Status in cloud-init:
  Won't Fix
Status in OpenStack Compute (nova):
  Fix Released
Status in nova package in Ubuntu:
  Fix Released
Status in nova source package in Oneiric:
  Fix Released

Bug description:
  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.

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




More information about the Ubuntu-openstack-bugs mailing list