resizefs module causes problems on LXC containers

Bug #800856 reported by Clint Byrum
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
cloud-init
Fix Released
Medium
Unassigned
cloud-init (Ubuntu)
Fix Released
Medium
Unassigned

Bug Description

$ sudo lxc-start -n natty-im
cloud-init start-local running: Wed, 22 Jun 2011 19:05:58 +0000. up 335311.61 seconds
no instance data found in start-local
init: cloud-init-local main process (25) terminated with status 1
init: cloud-init-nonet main process (26) killed by TERM signal
cloud-init start running: Wed, 22 Jun 2011 19:06:01 +0000. up 335314.42 seconds
found data source: DataSourceNoCloud [seed=/var/lib/cloud/seed/nocloud-net]
2011-06-22 19:06:01,362 - cc_resizefs.py[WARNING]: Failed to make device node to resize /
2011-06-22 19:06:01,362 - __init__.py[WARNING]: Traceback (most recent call last):
  File "/usr/lib/python2.7/dist-packages/cloudinit/CloudConfig/__init__.py", line 108, in run_cc_modules
    cc.handle(name, run_args, freq=freq)
  File "/usr/lib/python2.7/dist-packages/cloudinit/CloudConfig/__init__.py", line 72, in handle
    [ name, self.cfg, self.cloud, cloudinit.log, args ])
  File "/usr/lib/python2.7/dist-packages/cloudinit/__init__.py", line 307, in sem_and_run
    func(*args)
  File "/usr/lib/python2.7/dist-packages/cloudinit/CloudConfig/cc_resizefs.py", line 43, in handle
    os.mknod(devpth, 0400 | stat.S_IFBLK, dev)
OSError: [Errno 1] Operation not permitted

2011-06-22 19:06:01,362 - __init__.py[ERROR]: config handling of resizefs, None, [] failed

init: cloud-init main process (91) terminated with status 1
mountall: Event failed
init: ureadahead-other main process (104) terminated with status 4

This error shoudl be handled more gracefully since it will happen every time on LXC containers

Related branches

Scott Moser (smoser)
Changed in cloud-init (Ubuntu):
importance: Undecided → Medium
status: New → Triaged
Revision history for this message
Scott Moser (smoser) wrote :

Serge,
  Is there a good way that I can determine if I'm in an lxc container so that I can decide not to try to resize the filesystem on '/' ?
  At http://bazaar.launchpad.net/~cloud-init-dev/cloud-init/trunk/view/head:/cloudinit/CloudConfig/cc_resizefs.py , cloud-init does:
    try:
       st_dev=os.stat("/").st_dev
       dev=os.makedev(os.major(st_dev),os.minor(st_dev))
       os.mknod(devpth, 0400 | stat.S_IFBLK, dev)
    except:
        log.warn("Failed to make device node to resize /")
        raise
Its using the os.stat / to get the major, minor, then does an mknod of that so that it has a known device node to work on (rather than guessing the path to /dev/root). Either way, right now the mknod is failing, but I'm guessing the subsequent resize would also fail in a typical lxc setup.

Any suggestions on how to decide not to attempt resize?

Revision history for this message
Serge Hallyn (serge-hallyn) wrote :

Scott,

what most people do is look at /proc/1/cgroup and see whether it is '/'.

Since lxc and libvirt both tell init whether it is in a container, you can also create an upstart job like:

description "track if this is lxc instance"

start on startup

env container
env LIBVIRT_LXC_UUID

pre-start script
        if [ -z $container ]; then
                if [ -z $LIBVIRT_LXC_UUID ]; then
                        stop
                        exit 0
                fi
        fi
end script

Then if, after boot, 'status islxc' shows

 islxc start/running

you know you're in a container.

Revision history for this message
Serge Hallyn (serge-hallyn) wrote :

Do you think that job belongs in the 'lxcguest' package?

(I sort of think it does)

Scott Moser (smoser)
Changed in cloud-init (Ubuntu):
status: Triaged → Fix Committed
Scott Moser (smoser)
Changed in cloud-init (Ubuntu):
status: Fix Committed → Triaged
Changed in cloud-init:
status: New → Fix Committed
Revision history for this message
Launchpad Janitor (janitor) wrote :

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

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

  * do not give trace on failure to resize in lxc container (LP: #800856)
  * increase the timeout on url gets for "seedfrom" values (LP: #812646)
  * do not write entries for ephemeral0 on t1.micro (LP: #744019)

  [Adam Gandalman]
  * improve the updating of /etc/hosts with correct fqdn when possible
    (LP: #812539)

  [Avishai Ish-Shalom]
  * add chef support (cloudinit/CloudConfig/cc_chef.py) (LP: #798844)
 -- Scott Moser <email address hidden> Thu, 21 Jul 2011 05:51:03 -0400

Changed in cloud-init (Ubuntu):
status: Triaged → Fix Released
Scott Moser (smoser)
Changed in cloud-init:
importance: Undecided → Medium
Scott Moser (smoser)
Changed in cloud-init:
status: Fix Committed → Fix Released
Revision history for this message
Patrick Hetu (patrick-hetu) wrote :

I'm not sure if it's my setup or because of a recent change in libvirt or lxc but I'm still having the resize error on a lxc container:

2012-02-25 21:46:53,755 - __init__.py[DEBUG]: handling resizefs with freq=None and args=[]
2012-02-25 21:46:53,764 - cc_resizefs.py[WARNING]: Failed to make device node to resize /
2012-02-25 21:46:53,772 - __init__.py[WARNING]: Traceback (most recent call last):
  File "/usr/lib/python2.7/dist-packages/cloudinit/CloudConfig/__init__.py", line 108, in run_cc_modules
    cc.handle(name, run_args, freq=freq)
  File "/usr/lib/python2.7/dist-packages/cloudinit/CloudConfig/__init__.py", line 72, in handle
    [ name, self.cfg, self.cloud, cloudinit.log, args ])
  File "/usr/lib/python2.7/dist-packages/cloudinit/__init__.py", line 313, in sem_and_run
    func(*args)
  File "/usr/lib/python2.7/dist-packages/cloudinit/CloudConfig/cc_resizefs.py", line 46, in handle
    os.mknod(devpth, 0400 | stat.S_IFBLK, dev)
OSError: [Errno 1] Operation not permitted

This is what I got from /proc/1/cgroup instead of /

root@server-50:~# cat /proc/1/cgroup
1:blkio,freezer,devices,memory,cpuacct,cpu:/libvirt/lxc/instance-00000032

In the virtual server:

ii cloud-init 0.6.3~bzr502-0ubuntu1

In the openstack compute server:

ii libvirt-bin 0.9.8-2ubuntu10
ii lxc 0.7.5-3ubuntu30

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

@Patrick,
  Thanks for reporting. I've opened bug 941955, and we'll get that fixed.

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.