From: smbaker Date: Tue, 11 Dec 2012 01:51:31 +0000 (-0800) Subject: fix slices that use vsys not deleted correctly X-Git-Tag: nodemanager-2.1-16~1 X-Git-Url: http://git.onelab.eu/?p=nodemanager.git;a=commitdiff_plain;h=fdc12c02616ed5b342630cab90d01e85f43cfc1f fix slices that use vsys not deleted correctly --- diff --git a/sliver_lxc.py b/sliver_lxc.py index d4335c4..d61109b 100644 --- a/sliver_lxc.py +++ b/sliver_lxc.py @@ -4,6 +4,7 @@ import subprocess import sys +import time import os, os.path import grp from pwd import getpwnam @@ -221,9 +222,21 @@ class Sliver_LXC(Sliver_Libvirt, Initscript): command = ['/usr/sbin/userdel', '-f', '-r', name] logger.log_call(command, timeout=15*60) + if os.path.exists(os.path.join(containerDir,"vsys")): + # Slivers with vsys running will fail the subvolume delete. + # A more permanent solution may be to ensure that the vsys module + # is called before the sliver is destroyed. + logger.log("destroying vsys directory and restarting vsys") + logger.log_call(["rm", "-fR", os.path.join(containerDir, "vsys")]) + logger.log_call(["/etc/init.d/vsys", "restart", ]) + # Remove rootfs of destroyed domain command = ['btrfs', 'subvolume', 'delete', containerDir] logger.log_call(command, timeout=60) + if os.path.exists(containerDir): + # oh no, it's still here... + logger.log("WARNING: failed to destroy container %s" % containerDir) + logger.verbose('sliver_libvirt: %s destroyed.'%name)