apport can hang when checking for ec2 metadata

Bug #855651 reported by Scott Moser
12
This bug affects 1 person
Affects Status Importance Assigned to Milestone
apport (Ubuntu)
Fix Released
Low
Unassigned

Bug Description

data/general-hooks/ubuntu.py has something like this:
    ec2_instance = False
    for pkg in ('ec2-init', 'cloud-init'):
        try:
            if apport.packaging.get_version(pkg):
                ec2_instance = True
                break
    ...
    if ec2_instance:
        metadata_url = 'http://169.254.169.254/latest/meta-data/'
        ami_id_url = urljoin(metadata_url, 'ami-id')
        try:
            ami = urlopen(ami_id_url).read()
        except:
            ami = None

If cloud-init is installed, then it will try to do a get of http://169.254.169.254/latest/meta-data/ . In a restrictive firewall, that may be firewalled off, causing apport to appear to hang. we've actually seen this in a Canonical run datacenter where cloud-init was installed on a host system.

The problem can be remedied with:
  route add -host 169.254.169.254 reject

Then, after reporting the bug simply do:
  route del -host 169.254.169.254 reject

We should probably put a timeout on the urlopen call so that it doesn't hang indefinitely (or whatever the OS level socket timeout is, which is really large).

ProblemType: Bug
DistroRelease: Ubuntu 11.10
Package: apport 1.23-0ubuntu1
ProcVersionSignature: Ubuntu 3.0.0-11.18-server 3.0.4
Uname: Linux 3.0.0-11-server x86_64
ApportLog:

ApportVersion: 1.23-0ubuntu1
Architecture: amd64
CrashReports:
 600:0:0:13730:2011-09-20 12:15:44.651957665 -0400:2011-09-20 12:15:44.651957665 -0400:/var/crash/_usr_bin_add-apt-repository.0.crash
 775:1000:1000:4096:2011-09-19 20:46:56.988992051 -0400:2011-09-19 20:46:57.298997188 -0400:/var/crash/unpack
 600:1000:114:35637:2011-09-19 20:57:13.669684000 -0400:2011-09-19 20:59:01.801580663 -0400:/var/crash/_usr_lib_erlang_erts-5.8.3_bin_erlexec.107.crash
 600:0:0:17359:2011-09-20 17:57:45.687626739 -0400:2011-09-20 17:57:45.687626739 -0400:/var/crash/_usr_bin_nova-manage.0.crash
 600:0:0:246548:2011-09-19 22:15:29.600167786 -0400:2011-09-19 22:15:29.560167110 -0400:/var/crash/rabbitmq-server.0.crash
Date: Wed Sep 21 11:27:37 2011
PackageArchitecture: all
ProcEnviron:
 PATH=(custom, user)
 LANG=en_US.UTF-8
 SHELL=/bin/bash
SourcePackage: apport
UpgradeStatus: No upgrade log present (probably fresh install)

Revision history for this message
Scott Moser (smoser) wrote :
Changed in apport (Ubuntu):
importance: Undecided → Low
status: New → Confirmed
Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package apport - 2.0-0ubuntu3

---------------
apport (2.0-0ubuntu3) precise; urgency=low

  [ Martin Pitt ]
  * data/general-hooks/ubuntu.py: Do not capture stderr of lsb_release.
    (LP: #955111)

  [ Scott Moser ]
  * data/general-hooks/ubuntu.py: timeout on attempts to contact ec2 metadata
    service (LP: #855651)
 -- Martin Pitt <email address hidden> Tue, 03 Apr 2012 06:58:07 +0200

Changed in apport (Ubuntu):
status: Confirmed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Duplicates of this bug

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.