PL2445
authorMarc Fiuczynski <mef@cs.princeton.edu>
Wed, 17 Nov 2004 19:35:47 +0000 (19:35 +0000)
committerMarc Fiuczynski <mef@cs.princeton.edu>
Wed, 17 Nov 2004 19:35:47 +0000 (19:35 +0000)
- Reverted to using "du -s" rather than "du -b -s". Note that after
  several cases where the said test failed on a particular PlanetLab
  production machine, I can no longer cause the failure with "du -b -s".
  This indicates that there is something odd going on with vbuild and/or
  the underlying filesystem.

- Fix exit code bug. When the du size test fails, vuseradd will now exit
  with a non-zero code.  This way node manager wont think the
  /vservers/$NAME vserver was created, eventhough it was not.

- Removing slice account from /etc/passwd upon vbuild or "du" error.

scripts/vuseradd

index 36a0f95..af4c467 100755 (executable)
@@ -4,7 +4,7 @@
 #
 # Copyright (c) 2004  The Trustees of Princeton University (Trustees).
 #
-# $Id: vuseradd,v 1.15 2004/11/06 16:10:42 mlhuang Exp $
+# $Id: vuseradd,v 1.16 2004/11/12 18:44:09 mef Exp $
 #
 
 : ${UTIL_VSERVER_VARS:=$(dirname $0)/util-vserver-vars}
@@ -54,14 +54,24 @@ if [ ! -d "$VROOTDIR/$NAME" ] ; then
        "$PKGLIBDIR/vbuild" "$VROOTDIR/vserver-reference" "$TMP"
        RETVAL=$?
        # move it to .vcache when complete
-       if [ $RETVAL -ne 0 ] || \
-          [ $(du -b -s "$TMP" | awk "{ print \$1 }") -lt \
-             $(du -b -s "$VROOTDIR/vserver-reference" | awk "{ print \$1 }") ] ; then
+       if [ $RETVAL -ne 0 ] ; then 
            echo "Error $RETVAL building $VROOTDIR/$NAME"
            chattr -R -i "$TMP"
            rm -rf "$TMP"
+           userdel $NAME
            exit $RETVAL
        else
+           # sanity check
+           vnewsize=$(du -s "$TMP" | awk "{ print \$1 }")
+           vrefsize=$(du -s "$VROOTDIR/vserver-reference" | awk "{ print \$1 }")
+           if [ $vnewsize -lt $vrefsize ] ; then
+               echo "Error 'du -s $VROOTDIR/$NAME'=$vnewsize < 'du -s $VROOTDIR/vserver-reference'=$vrefsize"
+               chattr -R -i "$TMP"
+               rm -rf "$TMP"
+               userdel $NAME
+               exit 256
+           fi
+
            mv "$TMP" "$VROOTDIR/$NAME"
        fi
     fi