mkcephfs: error out if mon data directory is not empty

The ceph-mon --mkfs function no longer wipes out the directory; it is in
fact mostly a no-op that just verifies the dir exists.

So, ensure that the directory is empty at mkfs time.  This could
alternatively do an 'rm -r' in that directory (that is in fact what
ceph-mon used to do), but this is safer.

Signed-off-by: Sage Weil <sage@inktank.com>
This commit is contained in:
Sage Weil 2012-07-09 18:16:44 -07:00
parent 6b1835a92c
commit 4e66a3b98d

View File

@ -266,6 +266,12 @@ if [ -n "$initdaemon" ]; then
fi
if [ $type = "mon" ]; then
get_conf mon_data "/var/run/ceph/mon/ceph-$id" "mon data"
if [ `ls $mon_data | wc -l` -ne 0 ]; then
echo "ERROR: $name mon_data directory $mon_data is not empty."
echo " Please make sure that it is empty before running mkcephfs."
exit 1
fi
$BINDIR/ceph-mon -c $conf --mkfs -i $id --monmap $dir/monmap --osdmap $dir/osdmap -k $dir/keyring.mon
fi