[lxc-devel] [PATCH] Add remove_snapshots_entry() (rebased - v2)

Serge Hallyn serge.hallyn at ubuntu.com
Mon Sep 14 17:14:35 UTC 2015


Quoting Christian Brauner (christianvanbrauner at gmail.com):
> On Mon, Sep 14, 2015 at 02:50:39PM +0000, Serge Hallyn wrote:
> > Quoting Christian Brauner (christianvanbrauner at gmail.com):
> > > When creating ephemeral containers that have the option lxc.ephemeral = 1 set
> > > in their config, they will be destroyed on shutdown. As they are simple overlay
> > > clones of an existing container they should be registered in the lxc_snapshots
> > > file of the original container to stay consistent and adhere to the
> > > expectancies of the users. Most of all, it ensure that we cannot remove a
> > > container that has clones, even if they are just ephemeral snapshot-clones. The
> > > function adds further consistency because remove_snapshots_entry() ensures that
> > > ephemeral clone-snapshots deregister themselves from the lxc_snapshots file
> > > when they are destroyed.
> > > 
> > > POSSIBLE GLITCH:
> > > I was thinking hard about racing conditions and concurrent acces on the
> > > lxc_snapshots file when lxc-destroy is called on the container while we
> > > shutdown then container from inside. Here is what my thoughts are so far:
> > > 
> > > There should be no racing condition when lxc-destroy including all snapshots is
> > 
> > Note that lxcapi_destroy_with_snapshots() deletes the *snapshots*, not the
> > snapshot clones.  This is an unfortunate naming clash (which we could try
> > to correct henceforth but we need good names :), but they are different.
> > So anything under /var/lib/lxc/$container/snaps will be deleted.  But if
> > you've created an overlayfs clone, then containers listed in
> > /var/lib/lxc/$container/lxc_snapshots will not be deleted.  There is no
> > API call or program to automatically deleted those right now.  (I don't
> > think we want to write one, but a program to show which snapshots exist
> > would be good).
> > 
> > (Actually, there seems to be a bug right now - The sequence:
> > 
> > 	lxc-create -t download -n w1 -- -d ubuntu -r wily -a amd64
> > 	lxc-clone -s -B overlayfs -o w1 -n w2
> > 	lxc-snapshot -n w2
> > 	lxc-snapshot -n w2 -r snap0
> > 
> > does not result in /var/lib/lxc/w2/snap0 being deleted, so a subsequent
> > 
> > 	lxc-destroy -n w2
> > 
> > is refused.
> 
> Has the bug been introduced by changes I made. It does not look like it as this

D'oh, sorry, I was testing wrongly.  I was thinking '-r' meant
remove.

Please ignore :)

-serge


More information about the lxc-devel mailing list