lxc-destroy allows unsafe destruction of overlayfs sources

Bug #1212414 reported by Scott Moser
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
lxc (Ubuntu)
Fix Released
Medium
Unassigned

Bug Description

The gist of this bug is that 'lxc-destroy -n foo' should at least complain and require some sort of '--force' flag to remove 'foo' if there are containers that are using it for a source of their overlayfs clones.

Example:
## using daily ppa
$ sudo lxc-create -n source-precise-amd64 -t ubuntu-cloud -- \
   --release=precise --arch=amd64
$ sudo lxc-create -n source-precise-amd64 -t ubuntu-cloud -- \
    --release=precise --arch=amd64
ubuntu-cloudimg-query is /usr/bin/ubuntu-cloudimg-query
wget is /usr/bin/wget
Extracting container rootfs
Container source-precise-amd64 created.

$ sudo lxc-clone -o source-precise-amd64 --snapshot -B overlayfs -n my-clone
Created container my-clone as snapshot of source-precise-amd64

$ sudo lxc-destroy -n source-precise-amd64
$ echo $?
0

$ sudo lxc-start -n my-clone
lxc-start: No such file or directory - overlayfs: error mounting /var/lib/lxc/source-precise-amd64/rootfs onto /usr/lib/x86_64-linux-gnu/lxc options upperdir=/var/lib/lxc/my-clone/delta0,lowerdir=/var/lib/lxc/source-precise-amd64/rootfs
lxc-start: No such file or directory - failed to get real path for 'overlayfs:/var/lib/lxc/source-precise-amd64/rootfs:/var/lib/lxc/my-clone/delta0'
lxc-start: failed to mount rootfs
lxc-start: failed to setup rootfs for 'my-clone'
lxc-start: failed to setup the container
lxc-start: invalid sequence number 1. expected 2
lxc-start: failed to spawn 'my-clone'

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

My original lxcapi_clone plan included a 'lxc.snapshots' configuration file entry which would get bumped in the original container by lxcapi_clone, and dec'd by lxc-destroy. However, overlayfs is the only backing store that needs this, and doing this unilaterally would be wrong since in the btrfs case the original doesn't need to stick around.

So let me think a bit more if there's any more elegant solution, and please anyone chime in if you have one. Otherwise I'll probably go with lxc.snapshots after all, and just bump it at lxc-clone -B overlayfs -s.

Changed in lxc (Ubuntu):
status: New → Triaged
importance: Undecided → Medium
Revision history for this message
Serge Hallyn (serge-hallyn) wrote :

A patch has been sent upstream to fix this. Note it does not address 'lxc-start-ephemeral', only lxc-clone.

Changed in lxc (Ubuntu):
status: Triaged → Fix Committed
Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package lxc - 1.0.0~alpha1-0ubuntu2

---------------
lxc (1.0.0~alpha1-0ubuntu2) saucy; urgency=low

  * Add allow-stderr to autopkgtst restrictions as the Ubuntu template
    uses policy-rc.d to disable some daemons and that causes a message to
    be printed on stderr when the service tries to start.
 -- Stephane Graber <email address hidden> Thu, 12 Sep 2013 13:57:17 -0400

Changed in lxc (Ubuntu):
status: Fix Committed → 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.