Add check for minimum disk size v0.12
authorIustin Pop <iustin@google.com>
Tue, 30 Oct 2012 10:14:28 +0000 (11:14 +0100)
committerIustin Pop <iustin@google.com>
Tue, 30 Oct 2012 11:16:49 +0000 (12:16 +0100)
This fixes issue 164, and changes:

  Failure: command execution error:
  Could not add os for instance instance2 on node node4:
  OS create script failed (exited with exit code 1), last lines in the log file:
  tar: ./bin/df: Cannot open: No such file or directory
  tar: ./bin/ip: Cannot open: No such file or directory
  tar: ./bin/grep: Cannot open: No such file or directory
  tar: ./opt: Cannot mkdir: No space left on device
  tar: ./selinux: Cannot mkdir: No space left on device
  tar: Exiting with failure status due to previous errors

Into:

  Failure: command execution error:
  Could not add os for instance instance2 on node node4:
  OS create script failed (exited with exit code 1), last lines in the log file:
  Device size is too small (128 MB)
  Required size is at least 256MB

Signed-off-by: Iustin Pop <iustin@google.com>
Reviewed-by: Bernardo Dal Seno <bdalseno@google.com>

NEWS
README
create

diff --git a/NEWS b/NEWS
index aa8695d..a25b841 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -5,6 +5,9 @@ A few small bugfixes:
 
 - the defaults file is now installed automatically; even though all
   settings are commented out, this allows for easier configuration
+- require and check for a minimum device size; this makes error messages
+  much clearer, compared to tar's out of disk space errors (fixes issue
+  164)
 - it is now possible to override the "components" argument to
   debootstrap, to be able to install more packages (e.g. from contrib,
   or from universe) (fixes issue 254)
diff --git a/README b/README
index 3fe7dfb..34badc2 100644 (file)
--- a/README
+++ b/README
@@ -38,6 +38,10 @@ ganeti will look for OS definitions.
 Configuration of instance creation
 ----------------------------------
 
+Note: the minimum disk size accepted is 256MB, as ``debootstrap``
+requires disk space both for downloading the packages and installing
+them.
+
 The kind of instance created can be customized via a settings file. This
 file is not installed by default, as the instance creation will work
 without it. The creation scripts will look for it in
diff --git a/create b/create
index d07c274..827dad8 100755 (executable)
--- a/create
+++ b/create
 
 set -e
 
+# minimum device size is 256 MB, but we use 255 to account for
+# potential rounding
+declare -ri MIN_DEV_SIZE=$((255*1048576))
+
 . common.sh
 
 if [ "$GENERATE_CACHE" = "yes" -a ! -d "$CACHE_DIR" ]; then
@@ -36,6 +40,13 @@ if [ ! -b $blockdev ]; then
   CLEANUP+=("losetup -d $blockdev")
 fi
 
+DEVICE_SIZE=$(blockdev --getsize64 $blockdev)
+if [ "$DEVICE_SIZE" -lt $MIN_DEV_SIZE ]; then
+  echo "Device size is too small ($((DEVICE_SIZE/1048576)) MB)" 1>&2
+  echo "Required size is at least 256MB" 1>&2
+  exit 1
+fi
+
 if [ "$PARTITION_STYLE" = "none" ]; then
   filesystem_dev=$blockdev
 elif [ "$PARTITION_STYLE" = "msdos" ]; then
@@ -44,7 +55,7 @@ elif [ "$PARTITION_STYLE" = "msdos" ]; then
   filesystem_dev=$(map_disk0 $blockdev)
   CLEANUP+=("unmap_disk0 $blockdev")
 else
-  echo "Unknown partition style $PARTITION_STYLE"
+  echo "Unknown partition style $PARTITION_STYLE" 1>&2
   exit 1
 fi