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

Christian Brauner christianvanbrauner at gmail.com
Fri Sep 11 06:43:44 UTC 2015


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
called and the container in question is running, lxc-destroy will simply fail
with the warning that the clone is still running but lxc-destroy won't touch
the lxc_snapshots file. The offending container will then exit and delete the
container entry. lxc-destroy can then be called again and will delete the
remaining containers.

The strange case seems to be when we create another clone-snapshot while
another one shuts down. Does someone have any arguments against this way of
implementing it? Do we expect trouble? Do we need flocks in start.c and
lxccontainer.c?

(Another step for providing a consistent rewrite of lxc-clone +
lxc-start-ephemeral.)

Christian Brauner (1):
  Add remove_snapshots_entry()

 src/lxc/start.c | 43 ++++++++++++++++++++-----------------------
 1 file changed, 20 insertions(+), 23 deletions(-)

-- 
2.5.1



More information about the lxc-devel mailing list