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

Bug #407949 reported by Eric Hammond on 2009-08-02
This bug affects 1 person
Affects Status Importance Assigned to Milestone
EC2 init scripts
Ubuntu on EC2
ec2-init (Ubuntu)

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 = ""
  elif zone.startswith("eu"):
        archive = ""


          if location.startswith("us"):
        elif location.startswith("eu"):

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

Chuck Short (zulcss) on 2009-08-06
Changed in ubuntu-on-ec2:
status: New → Confirmed
importance: Undecided → Medium
Scott Moser (smoser) wrote :

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

Scott Moser (smoser) wrote :

suggested patch is attached.

Scott Moser (smoser) on 2009-09-08
tags: added: ec2-images
Scott Moser (smoser) on 2009-09-08
Changed in ec2-init (Ubuntu):
status: New → Confirmed
importance: Undecided → Medium
Changed in ubuntu-on-ec2:
status: Confirmed → Invalid
Eric Hammond (esh) on 2009-09-11
Changed in ec2-init:
status: New → Invalid
Scott Moser (smoser) on 2009-10-16
tags: added: uec-images
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 (

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) on 2009-10-20
Changed in ec2-init (Ubuntu):
status: Confirmed → In Progress
Matt Zimmerman (mdz) on 2009-10-20
Changed in ec2-init (Ubuntu Karmic):
milestone: none → ubuntu-9.10
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.

Scott Moser (smoser) wrote :

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

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  Edit
Everyone can see this information.

Other bug subscribers