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>
export HSMTOOL_EVENT_FIFO=${HSMTOOL_EVENT_FIFO:=""}
export HSMTOOL_TESTDIR
export HSMTOOL_BASE=$(basename "$HSMTOOL" | cut -f1 -d" ")
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)
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
HSM_ARCHIVE_NUMBER=2
# The test only support up to 10 MDTs
local lustre_mntpnt=${2:-${MOUNT2:-$MOUNT}}
local arc_id=$3
local hsm_root=${4:-$(copytool_device $facet)}
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" ]] &&
local agent=$(facet_active_host $facet)
if [[ -z "$arc_id" ]] &&
if $HSM_ARCHIVE_PURGE; then
echo "Purging archive on $agent"
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"
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
# 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"
[[ -z "$arc_id" ]] || cmd+=" --archive $arc_id"
[[ -z "$HSMTOOL_UPDATE_INTERVAL" ]] ||
cmd+=" --update-interval $HSMTOOL_UPDATE_INTERVAL"
local agt_facet=$SINGLEAGT
local agt_hosts=${1:-$(facet_active_host $agt_facet)}
local hsm_root=$(copytool_device $agt_facet)
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
local i
local facet
local param
done
if do_facet $agt_facet "df $hsm_root" >/dev/null 2>&1 ; then
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/*"
echo $raw_event | python -c "$json_parser"
}
echo $raw_event | python -c "$json_parser"
}
-# populate MDT device array
-get_mdt_devices
-
# initiate variables
init_agt_vars
# initiate variables
init_agt_vars
+# populate MDT device array
+get_mdt_devices
+
# cleanup from previous bad setup
kill_copytools
# cleanup from previous bad setup
kill_copytools
facet_number() {
local facet=$1
facet_number() {
local facet=$1
- if [ $facet == mgs ]; then
+ if [ $facet == mgs ] || [ $facet == client ]; then