cloud-init should try harder to get domainname in fallback case

Bug #850206 reported by Scott Moser
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
cloud-init
Fix Released
Undecided
Scott Moser
cloud-init (Ubuntu)
Fix Released
Medium
Scott Moser

Bug Description

Right now, if there is no 'local-hostname' in a DataSource's meta-data, then cloud-init will default the domain portion of the fqdn to be 'localdomain'. I did this because determining a system's fully qualified domain name is non-trivial, especially if this is occuring while network interfaces might be coming up or are not up. See the manpage of 'hostname' for warnings around '--fqdn'.

This was affecting our cobbler based installed systems. The ensemble/juju scripts were using 'hostname -f' to get a hostname that would be reachable. (That is still non-ideal due to the issues in hostname(1)).

These instances would be provisioned to have an entry in /etc/hosts like:
 IP FQDN ALIAS [ALIAS2 [ ... ] ]
but cloud-init would then update the entry to have 'localdomain' as there was no local-hostname.

So, The solution proposed is:

- boot instance with old cloud-init
- verify it has cloud-init written entry in /etc/hosts
  127.0.1.1 server-912.localdomain server-912
  on ec2, 'localdomain' would be 'internal'. In either case, modify this, so that it the domain is 'mydomain' rather than 'localdomain' (so you can verify cloud-init changed that after reboot)
- add seed content without a local-hostname
  sudo rm -Rf /var/lib/cloud/
  sudo mkdir -p /var/lib/cloud/seed/nocloud-net
  python -c 'import boto.utils, pprint; md=boto.utils.get_instance_metadata(); del md["local-hostname"]; pprint.pprint(md);' > /tmp/meta-data
  sudo cp /tmp/meta-data /var/lib/cloud/seed/nocloud-net/meta-data
  sudo touch /var/lib/cloud/seed/nocloud-net/user-data
- sudo reboot

# after reboot, 'hostname -f' should will show 'localdomain'
# $ hostname -f
# server-912.localdomain
# and /etc/hosts has been updated by cloud-init.

That is the bug we want to fix.
With our fixed available, we can then:

- now, update /etc/hosts to have '$(hostname).mydomain' again
  sudo sed -i '/^127.0.1.1/d' /etc/hosts
  echo "127.0.1.1 $(hostname).mydomain $(hostname)" | sudo tee -a /etc/hosts

- now, install new cloud-init
  sudo dpkg -i cloud-init_0.6.2_all.deb
- clean meta-data
  for d in /var/lib/cloud/*; do [ "${d%seed}" = "$d" ] && sudo rm -Rf $d; done
- reboot
- verify that the host should now have:
  $ hostname -f
  server-912.mydomain

ProblemType: Bug
DistroRelease: Ubuntu 11.10
Package: cloud-init 0.6.1-0ubuntu17
ProcVersionSignature: User Name 3.0.0-11.17-virtual 3.0.4
Uname: Linux 3.0.0-11-virtual x86_64
ApportVersion: 1.22.1-0ubuntu2
Architecture: amd64
Date: Wed Sep 14 17:13:08 2011
Ec2AMI: ami-00000085
Ec2AMIManifest: FIXME
Ec2AvailabilityZone: nova
Ec2InstanceType: m1.small
Ec2Kernel: unavailable
Ec2Ramdisk: unavailable
PackageArchitecture: all
ProcEnviron:
 LANG=en_US.UTF-8
 SHELL=/bin/bash
SourcePackage: cloud-init
UpgradeStatus: No upgrade log present (probably fresh install)

Related branches

Revision history for this message
Scott Moser (smoser) wrote :
Changed in cloud-init:
assignee: nobody → Scott Moser (smoser)
status: New → In Progress
Changed in cloud-init (Ubuntu):
assignee: nobody → Scott Moser (smoser)
importance: Undecided → Medium
status: New → Confirmed
Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package cloud-init - 0.6.1-0ubuntu19

---------------
cloud-init (0.6.1-0ubuntu19) oneiric; urgency=low

  * If local-hostname is not in meta-data, attempt to look up hostname in
    an alias in /etc/hosts. This will avoid setting domain portion of fqdn
    to 'localdomain' in some cases (LP: #850206).
 -- Scott Moser <email address hidden> Wed, 14 Sep 2011 15:15:00 -0400

Changed in cloud-init (Ubuntu):
status: Confirmed → Fix Released
Revision history for this message
Scott Moser (smoser) wrote :

Fixed in trunk revision 448

Changed in cloud-init:
status: In Progress → Fix Committed
Scott Moser (smoser)
Changed in cloud-init:
status: Fix Committed → Fix Released
Revision history for this message
James Falcon (falcojr) wrote :
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.