From 4697d74e00225c06b74ce6d5f850b54eb8383284 Mon Sep 17 00:00:00 2001 From: Andreas Dilger Date: Thu, 14 Sep 2023 14:59:58 -0600 Subject: [PATCH] LU-17050 tests: remove sanity-sec IDENTITY_UPCALL In sanity-sec.sh there was an IDENTITY_UPCALL variable that conflicted with an identically-named global variable in test-parameters. Due to new checks by Gerrit Janitor, this was causing any patch that ran sanity-sec.sh to log a warning. Remove the parameter from sanity-sec.sh as it is unused. Update code style in functions upcating identity_upcall. Lustre-change: https://review.whamcloud.com/52400 Lustre-commit: 6a04acde6d0900f3e7fb3ed4929dc98d58bd194c Test-Parameters: trivial testlist=sanity-sec mdscount=2 mdtcount=4 Signed-off-by: Andreas Dilger Change-Id: I2f2ace33cf01153d16f4f25038065d33443ebbe5 Change-Id: I2bda5557d62d41f170eda55e66cdb8add28c85c7 Reviewed-by: Sebastien Buisson Reviewed-by: Alex Deiter Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/55438 Tested-by: jenkins Tested-by: Maloo Reviewed-by: Oleg Drokin --- lustre/tests/sanity-sec.sh | 16 ++++++------ lustre/tests/sanity.sh | 6 ++--- lustre/tests/test-framework.sh | 55 ++++++++++++++++-------------------------- 3 files changed, 31 insertions(+), 46 deletions(-) diff --git a/lustre/tests/sanity-sec.sh b/lustre/tests/sanity-sec.sh index 9f74608..dfef66f 100755 --- a/lustre/tests/sanity-sec.sh +++ b/lustre/tests/sanity-sec.sh @@ -96,12 +96,10 @@ else echo "without GSS support" fi -MDT=$(do_facet $SINGLEMDS lctl get_param -N "mdt.\*MDT0000" | - cut -d. -f2 || true) -[ -z "$MDT" ] && error "fail to get MDT device" && exit 1 +MDT=$(mdtname_from_index 0 $MOUNT) +[[ -z "$MDT" ]] && error "fail to get MDT0000 device name" && exit 1 do_facet $SINGLEMDS "mkdir -p $CONFDIR" IDENTITY_FLUSH=mdt.$MDT.identity_flush -IDENTITY_UPCALL=mdt.$MDT.identity_upcall SAVE_PWD=$PWD @@ -128,7 +126,7 @@ sec_login() { declare -a identity_old sec_setup() { - for num in $(seq $MDSCOUNT); do + for ((num = 1; num <= $MDSCOUNT; num++)); do switch_identity $num true || identity_old[$num]=$? done @@ -203,7 +201,7 @@ run_test 1 "setuid/gid =============================" # bug 3285 - supplementary group should always succeed. # NB: the supplementary groups are set for local client only, # as for remote client, the groups of the specified uid on MDT -# will be obtained by upcall /sbin/l_getidentity and used. +# will be obtained by upcall /usr/sbin/l_getidentity and used. test_4() { [[ "$MDS1_VERSION" -ge $(version_code 2.6.93) ]] || [[ "$MDS1_VERSION" -ge $(version_code 2.5.35) && @@ -211,7 +209,7 @@ test_4() { skip "Need MDS version at least 2.6.93 or 2.5.35" rm -rf $DIR/$tdir - mkdir -p $DIR/$tdir + mkdir_on_mdt0 -p $DIR/$tdir chmod 0771 $DIR/$tdir chgrp $ID0 $DIR/$tdir $RUNAS_CMD -u $ID0 ls $DIR/$tdir || error "setgroups (1)" @@ -5122,8 +5120,8 @@ run_test 62 "e2fsck with encrypted files" log "cleanup: ======================================================" sec_unsetup() { - for num in $(seq $MDSCOUNT); do - if [ "${identity_old[$num]}" = 1 ]; then + for ((num = 1; num <= $MDSCOUNT; num++)); do + if [[ "${identity_old[$num]}" == 1 ]]; then switch_identity $num false || identity_old[$num]=$? fi done diff --git a/lustre/tests/sanity.sh b/lustre/tests/sanity.sh index d5093cf..4bc60eb 100755 --- a/lustre/tests/sanity.sh +++ b/lustre/tests/sanity.sh @@ -11543,7 +11543,7 @@ test_103a() { declare -a identity_old - for num in $(seq $MDSCOUNT); do + for ((num = 1; num <= $MDSCOUNT; num++)); do switch_identity $num true || identity_old[$num]=$? done @@ -11606,8 +11606,8 @@ test_103a() { cd $SAVE_PWD umask $SAVE_UMASK - for num in $(seq $MDSCOUNT); do - if [ "${identity_old[$num]}" = 1 ]; then + for ((num = 1; num <= $MDSCOUNT; num++)); do + if [[ "${identity_old[$num]}" == 1 ]]; then switch_identity $num false || identity_old[$num]=$? fi done diff --git a/lustre/tests/test-framework.sh b/lustre/tests/test-framework.sh index 83bbcba..9c6384c 100755 --- a/lustre/tests/test-framework.sh +++ b/lustre/tests/test-framework.sh @@ -23,7 +23,8 @@ export SK_S2S=${SK_S2S:-false} export SK_S2SNM=${SK_S2SNM:-TestFrameNM} export SK_S2SNMCLI=${SK_S2SNMCLI:-TestFrameNMCli} export SK_SKIPFIRST=${SK_SKIPFIRST:-true} -export IDENTITY_UPCALL=default +# whether identity upcall is enabled (true), disabled (false), or default +export IDENTITY_UPCALL=${IDENTITY_UPCALL:-default} export QUOTA_AUTO=1 export FLAKEY=${FLAKEY:-true} # specify environment variable containing batch job name for server statistics @@ -307,7 +308,7 @@ init_test_env() { export L_GETIDENTITY=${L_GETIDENTITY:-"$LUSTRE/utils/l_getidentity"} if [ ! -f "$L_GETIDENTITY" ]; then - if `which l_getidentity > /dev/null 2>&1`; then + if $(which l_getidentity > /dev/null 2>&1); then export L_GETIDENTITY=$(which l_getidentity) else export L_GETIDENTITY=NONE @@ -379,15 +380,6 @@ init_test_env() { ;; esac - case "x$IDUP" in - xtrue) - IDENTITY_UPCALL=true - ;; - xfalse) - IDENTITY_UPCALL=false - ;; - esac - export LOAD_MODULES_REMOTE=${LOAD_MODULES_REMOTE:-false} # Paths on remote nodes, if different @@ -4949,35 +4941,30 @@ umount_client() { grep " $1 " /proc/mounts && zconf_umount $HOSTNAME $* } -# return value: -# 0: success, the old identity set already. -# 1: success, the old identity does not set. +# usage: switch_identity MDSNUM ENABLE_UPCALL +# +# return values: +# 0: success, the identity upcall was previously enabled already. +# 1: success, the identity upcall was previously disabled. # 2: fail. switch_identity() { - local num=$1 - local switch=$2 - local j=`expr $num - 1` - local MDT="`(do_facet mds$num lctl get_param -N mdt.*MDT*$j 2>/dev/null | cut -d"." -f2 2>/dev/null) || true`" + local num=$1 + local enable=$2 + local facet=mds$num + local MDT="$(mdtname_from_index $((num - 1)) $MOUNT)" + local upcall="$L_GETIDENTITY" - if [ -z "$MDT" ]; then - return 2 - fi + [[ -n "$MDT" ]] || return 2 - local old="`do_facet mds$num "lctl get_param -n mdt.$MDT.identity_upcall"`" + local param="mdt.$MDT.identity_upcall" + local old="$(do_facet $facet "lctl get_param -n $param")" - if $switch; then - do_facet mds$num "lctl set_param -n mdt.$MDT.identity_upcall \"$L_GETIDENTITY\"" - else - do_facet mds$num "lctl set_param -n mdt.$MDT.identity_upcall \"NONE\"" - fi + [[ "$enable" == "true" ]] || upcall="NONE" - do_facet mds$num "lctl set_param -n mdt/$MDT/identity_flush=-1" + do_facet $facet "lctl set_param -n $param='$upcall'" || return 2 + do_facet $facet "lctl set_param -n mdt.$MDT.identity_flush=-1" - if [ $old = "NONE" ]; then - return 1 - else - return 0 - fi + [[ "$old" != "NONE" ]] # implicit "&& return 0 || return 1" } remount_client() @@ -5037,7 +5024,7 @@ mountmds() { eval $varname=$host fi done - if [ $IDENTITY_UPCALL != "default" ]; then + if [[ "$IDENTITY_UPCALL" != "default" ]]; then switch_identity $num $IDENTITY_UPCALL fi done -- 1.8.3.1