Whamcloud - gitweb
LU-7110 tests: sanity-hsm.sh can erase all files on filesystem 91/16291/7
authorParinay Kondekar <parinay.kondekar@seagate.com>
Tue, 12 Apr 2016 06:44:03 +0000 (12:14 +0530)
committerOleg Drokin <oleg.drokin@intel.com>
Thu, 21 Apr 2016 02:26:27 +0000 (02:26 +0000)
For SINGLEAGT=client, $HSM_ARCHIVE & $hsm_root is empty.
Thus purging of archive in copytool_setup() will result
in execution of "rm -rf /*", resulting in permanent loss
of files as well as cluster node.

This change fixes it by checking the respective variables
like HSM_ARCHIVE or hsm_root to be non-empty.

Change-Id: I73cdc08a58409ae1f3ba85a9d12077062a38b321
Seagate-Bug-Id: MRP-2659
Signed-off-by: Parinay Kondekar <parinay.kondekar@seagate.com>
Reviewed-on: http://es-gerrit.xyus.xyratex.com:8080/6471
Tested-by:Jenkins
Reviewed-by: Elena V. Gryaznova <elena.gryaznova@seagate.com>
Reviewed-by: Alexander Lezhoev <alexander.lezhoev@seagate.com>
Reviewed-on: http://review.whamcloud.com/16291
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: Andreas Dilger <andreas.dilger@intel.com>
Reviewed-by: jacques-Charles Lafoucriere <jacques-charles.lafoucriere@cea.fr>
Reviewed-by: Oleg Drokin <oleg.drokin@intel.com>
lustre/tests/sanity-hsm.sh
lustre/tests/test-framework.sh

index f73a502..9f8ec9c 100755 (executable)
@@ -103,7 +103,16 @@ init_agt_vars() {
        export HSMTOOL_EVENT_FIFO=${HSMTOOL_EVENT_FIFO:=""}
        export HSMTOOL_TESTDIR
        export HSMTOOL_BASE=$(basename "$HSMTOOL" | cut -f1 -d" ")
+       # $hsm_root/$HSMTMP Makes $hsm_root dir path less generic to ensure
+       # rm -rf $hsm_root/* is safe even if $hsm_root becomes unset to avoid
+       # deleting everything in filesystem, independent of any copytool.
+       export HSMTMP=${HSMTMP:-"shsm"}
+
        HSM_ARCHIVE=$(copytool_device $SINGLEAGT)
+
+       [ -z "${HSM_ARCHIVE// /}" ] && error "HSM_ARCHIVE is empty!"
+       HSM_ARCHIVE=$HSM_ARCHIVE/$HSMTMP
+
        HSM_ARCHIVE_NUMBER=2
 
        # The test only support up to 10 MDTs
@@ -244,6 +253,9 @@ copytool_setup() {
        local lustre_mntpnt=${2:-${MOUNT2:-$MOUNT}}
        local arc_id=$3
        local hsm_root=${4:-$(copytool_device $facet)}
+
+       [ -z "${hsm_root// /}" ] && error "copytool_setup: hsm_root empty!"
+
        local agent=$(facet_active_host $facet)
 
        if [[ -z "$arc_id" ]] &&
@@ -254,14 +266,16 @@ copytool_setup() {
 
        if $HSM_ARCHIVE_PURGE; then
                echo "Purging archive on $agent"
-               do_facet $facet "rm -rf $hsm_root/*"
+               do_facet $facet "rm -rf $hsm_root/$HSMTMP/*"
        fi
 
        echo "Starting copytool $facet on $agent"
-       do_facet $facet "mkdir -p $hsm_root" || error "mkdir '$hsm_root' failed"
+       do_facet $facet "mkdir -p $hsm_root/$HSMTMP/" ||
+                       error "mkdir '$hsm_root/$HSMTMP' failed"
        # bandwidth is limited to 1MB/s so the copy time is known and
        # independent of hardware
-       local cmd="$HSMTOOL $HSMTOOL_VERBOSE --daemon --hsm-root $hsm_root"
+       local cmd="$HSMTOOL $HSMTOOL_VERBOSE --daemon"
+       cmd+=" --hsm-root $hsm_root/$HSMTMP"
        [[ -z "$arc_id" ]] || cmd+=" --archive $arc_id"
        [[ -z "$HSMTOOL_UPDATE_INTERVAL" ]] ||
                cmd+=" --update-interval $HSMTOOL_UPDATE_INTERVAL"
@@ -301,6 +315,9 @@ copytool_cleanup() {
        local agt_facet=$SINGLEAGT
        local agt_hosts=${1:-$(facet_active_host $agt_facet)}
        local hsm_root=$(copytool_device $agt_facet)
+
+       [ -z "${hsm_root// /}" ] && error "copytool_cleanup: hsm_root empty!"
+
        local i
        local facet
        local param
@@ -349,7 +366,7 @@ copytool_cleanup() {
        done
 
        if do_facet $agt_facet "df $hsm_root" >/dev/null 2>&1 ; then
-               do_facet $agt_facet "rm -rf $hsm_root/*"
+               do_facet $agt_facet "rm -rf $hsm_root/$HSMTMP/*"
        fi
 }
 
@@ -794,12 +811,12 @@ parse_json_event() {
        echo $raw_event | python -c "$json_parser"
 }
 
-# populate MDT device array
-get_mdt_devices
-
 # initiate variables
 init_agt_vars
 
+# populate MDT device array
+get_mdt_devices
+
 # cleanup from previous bad setup
 kill_copytools
 
index c413a35..9037f7e 100755 (executable)
@@ -817,7 +817,7 @@ facet_type() {
 facet_number() {
        local facet=$1
 
-       if [ $facet == mgs ]; then
+       if [ $facet == mgs ] || [ $facet == client ]; then
                return 1
        fi