Browse code

woot! more reliable lxc teardown

Anthony Young authored on 2011/09/13 19:02:38
Showing 1 changed files
... ...
@@ -12,9 +12,11 @@ WARMCACHE=${WARMCACHE:-0}
12 12
 
13 13
 # Destroy any existing container
14 14
 lxc-stop -n $CONTAINER
15
-sleep 2
15
+sleep 1
16
+cgdelete -r cpu,net_cls:$CONTAINER
17
+sleep 1
16 18
 lxc-destroy -n $CONTAINER
17
-sleep 2
19
+sleep 1
18 20
 
19 21
 CACHEDIR=/var/cache/lxc/natty/rootfs-amd64
20 22
 if [ "$WARMCACHE" = "1" ]; then
... ...
@@ -68,6 +70,7 @@ EOF
68 68
 INSTALL_SH=$ROOTFS/root/install.sh
69 69
 cat > $INSTALL_SH <<EOF
70 70
 #!/bin/bash
71
+echo \#\!/bin/sh -e > /etc/rc.local
71 72
 echo "nameserver $NAMESERVER" | resolvconf -a eth0
72 73
 sleep 1
73 74
 # Create a stack user that is a member of the libvirtd group so that stack 
... ...
@@ -108,3 +111,12 @@ mount none -t cgroup /cgroup
108 108
 
109 109
 # Start our container
110 110
 lxc-start -d -n $CONTAINER
111
+
112
+cat << EOF > /bin/remove_dead_cgroup.shecho
113
+"Removing dead cgroup .$CONTAINER." >> /var/log/cgroup
114
+rmdir /cgroup/$CONTAINER >> /var/log/cgroup 2>&1
115
+echo "return value was $?" >> /var/log/cgroup
116
+EOF
117
+chmod 755 /bin/remove_dead_cgroup.sh
118
+echo /bin/remove_dead_cgroup.sh > /cgroup/release_agent
119
+echo 1 > /cgroup/notify_on_release