ec2-init: ec2-set-defaults needs better defaults for non US/EU regions

Bug #407949 reported by Eric Hammond
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
EC2 init scripts
Invalid
Undecided
Unassigned
Ubuntu on EC2
Invalid
Medium
Unassigned
Karmic
New
Undecided
Unassigned
ec2-init (Ubuntu)
Fix Released
Medium
Unassigned
Karmic
Fix Released
Medium
Unassigned

Bug Description

This report applies to the code found in the dev testing ami-af3fdec6

The code in /usr/sbin/ec2-set-defaults has reasonable options for regions starting with "us" and "eu" but it lacks defaults for other regions.

Amazon is sure to add more EC2 regions in non US/EU areas and this code should pick a default for them. Even if it ends up not being the right choice it should still work until the code can be enhanced to pick a better option.

The code in question looks like:

  if zone.startswith("us"):
        archive = "http://us.ec2.archive.ubuntu.com/ubuntu"
  elif zone.startswith("eu"):
        archive = "http://eu.ec2.archive.ubuntu.com/ubuntu"

and

          if location.startswith("us"):
            lang='en_US.UTF-8'
        elif location.startswith("eu"):
            lang='en_GB.UTF-8'

Note the lack of an "else" in these conditionals.

Chuck Short (zulcss)
Changed in ubuntu-on-ec2:
status: New → Confirmed
importance: Undecided → Medium
Revision history for this message
Scott Moser (smoser) wrote :

The 'archive' hunk above is a duplicate of bug 387027. But the locale issue is still present.

Revision history for this message
Scott Moser (smoser) wrote :

suggested patch is attached.

Scott Moser (smoser)
tags: added: ec2-images
Scott Moser (smoser)
Changed in ec2-init (Ubuntu):
status: New → Confirmed
importance: Undecided → Medium
Changed in ubuntu-on-ec2:
status: Confirmed → Invalid
Eric Hammond (esh)
Changed in ec2-init:
status: New → Invalid
Scott Moser (smoser)
tags: added: uec-images
Revision history for this message
Scott Moser (smoser) wrote :

This affects the uec instances of the ec2/uec images negatively. You can see the obvious problem here:

    def get_location_from_availability_zone(self, availability_zone):
        if availability_zone.startswith('us-'):
            return 'us'
        elif availability_zone.startswith('eu-'):
            return 'eu'
        raise Exception('Could not determine location')

That exception is not caught in the caller (ec2-set-defaults.py):

def main():
    ec2 = ec2init.EC2Init()

    availability_zone = ec2.get_availability_zone()
    location = ec2.get_location_from_availability_zone(availability_zone)

The result is that ec2-set-defaults dies before 'apply_locale' is called.

As such, locale-gen and update-locale are not called in the instance. That causes things like:

$ man asdf
man: can't set the locale; make sure $LC_* and $LANG are correct
No manual entry for asdf

To fix that, you can do what ec2-init would have done:
$ sudo locale-gen en_US.UTF-8
Generating locales...
  en_US.UTF-8... done
Generation complete.
$ sudo update-locale en_US.UTF-8
$ echo "LANG=en_US.UTF-8" | sudo tee /etc/default/locale

Scott Moser (smoser)
Changed in ec2-init (Ubuntu):
status: Confirmed → In Progress
Matt Zimmerman (mdz)
Changed in ec2-init (Ubuntu Karmic):
milestone: none → ubuntu-9.10
Revision history for this message
Scott Moser (smoser) wrote :

See Attached patch for fix. We may chose to do other things in upstream ec2-init, but for karmic this will fix the problem noted in comment 3.

Revision history for this message
Scott Moser (smoser) wrote :

Note, i've tested the patch at comment 4 and verified it functions on ec2 and uec.

Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package ec2-init - 0.4.999-0ubuntu4

---------------
ec2-init (0.4.999-0ubuntu4) karmic; urgency=low

  * set locale to en_US.UTF-8 if get_location_from_availability_zone
    doesn't have a match (LP: #407949)

 -- Scott Moser <email address hidden> Tue, 20 Oct 2009 09:57:49 -0400

Changed in ec2-init (Ubuntu Karmic):
status: In Progress → Fix Released
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.