From 59d37265acf250b1b29c186020c55e9df0ef4215 Mon Sep 17 00:00:00 2001 From: Venky Shankar Date: Thu, 1 Aug 2013 13:22:34 +0530 Subject: gverify/glusterd : Added check to warn the user of existing files in slave volume Change-Id: I41c9fb44613386189d9f3c090729f4ded8e4dea8 BUG: 990997 Signed-off-by: Avra Sengupta Signed-off-by: Venky Shankar Reviewed-on: http://review.gluster.org/5453 Tested-by: Gluster Build System Reviewed-by: Amar Tumballi Reviewed-by: Anand Avati --- geo-replication/src/gverify.sh | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) (limited to 'geo-replication/src') diff --git a/geo-replication/src/gverify.sh b/geo-replication/src/gverify.sh index 186af53a4..f10e21ed6 100755 --- a/geo-replication/src/gverify.sh +++ b/geo-replication/src/gverify.sh @@ -61,10 +61,11 @@ exit 1; fi; cd \$d; available_size=\$(df \$d | tail -1 | awk "{print \\\$4}"); +no_of_files=\$(find \$d -maxdepth 0 -empty); umount -l \$d; rmdir \$d; ver=\$(gluster --version | head -1 | cut -f2 -d " "); -echo \$available_size:\$ver; +echo \$available_size:\$ver:\$no_of_files:; }; cd /tmp; [ x$VOL != x ] && do_verify $VOL; @@ -102,7 +103,9 @@ function main() slave_size=$(echo $slave_data | cut -f1 -d':'); master_version=$(echo $master_data | cut -f2 -d':'); slave_version=$(echo $slave_data | cut -f2 -d':'); + slave_no_of_files=$(echo $slave_data | cut -f3 -d':'); log_file=$4 + > $log_file if [[ "x$master_size" = "x" || "x$master_version" = "x" || "$master_size" -eq "0" ]]; then echo "Unable to fetch master volume details." > $log_file; @@ -119,20 +122,19 @@ function main() exit 1; fi; - if [ $slave_size -ge $(($master_size - $BUFFER_SIZE )) ]; then - echo "Total size of master is lesser than available size of slave." > $log_file; - else - echo "Total size of master is greater than available size of slave." > $log_file; + if [ ! $slave_size -ge $(($master_size - $BUFFER_SIZE )) ]; then + echo "Total size of master is greater than available size of slave." >> $log_file; ERRORS=$(($ERRORS + 1)); - exit $ERRORS; fi; - if [[ $master_version < $slave_version || $master_version == $slave_version ]]; then - echo "Gluster version of master and slave matches." > $log_file; - else - echo "Gluster version mismatch between master and slave." > $log_file; + if [ -z $slave_no_of_files ]; then + echo "$2::$3 is not empty. Please delete existing files in $2::$3 and retry, or use force to continue without deleting the existing files." >> $log_file; + ERRORS=$(($ERRORS + 1)); + fi; + + if [[ $master_version > $slave_version ]]; then + echo "Gluster version mismatch between master and slave." >> $log_file; ERRORS=$(($ERRORS + 1)); - exit $ERRORS; fi; exit $ERRORS; -- cgit