From ff2a6f446bcbd71bdc01116e70f1f91177106ff4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A9lix-Antoine=20Fortin?= Date: Mon, 23 Oct 2023 21:41:56 -0400 Subject: [PATCH] Use SSS_NSS_USE_MEMCACHE=no instead of sss_cache invalidation --- site/profile/files/accounts/account_functions.sh | 7 +++---- site/profile/templates/accounts/mkproject.sh.epp | 9 ++++----- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/site/profile/files/accounts/account_functions.sh b/site/profile/files/accounts/account_functions.sh index b672bdd13..b468279f0 100644 --- a/site/profile/files/accounts/account_functions.sh +++ b/site/profile/files/accounts/account_functions.sh @@ -4,8 +4,7 @@ wait_id () { local USERNAME=$1 local FOUND=0 for i in $(seq 1 12); do - if ! id $USERNAME; then - sss_cache -u $USERNAME + if ! SSS_NSS_USE_MEMCACHE=no id $USERNAME; then sleep 5 else FOUND=1 @@ -28,7 +27,7 @@ mkhome () { echo "$USERNAME is not showing up in SSSD after 1min - cannot make its home." fi - local USER_HOME=$(getent passwd $USERNAME | cut -d: -f6) + local USER_HOME=$(SSS_NSS_USE_MEMCACHE=no getent passwd $USERNAME | cut -d: -f6) local MNT_USER_HOME="/mnt${USER_HOME}" for i in $(seq 1 5); do rsync -opg -r -u --chown=$USERNAME:$USERNAME --chmod=Dg-rwx,o-rwx,Fg-rwx,o-rwx,u+X /etc/skel.ipa/ ${MNT_USER_HOME} @@ -56,7 +55,7 @@ mkscratch () { if [[ ! -d "${MNT_USER_SCRATCH}" ]]; then mkdir -p ${MNT_USER_SCRATCH} if [ "$WITH_HOME" == "true" ]; then - local USER_HOME=$(getent passwd $USERNAME | cut -d: -f6) + local USER_HOME=$(SSS_NSS_USE_MEMCACHE=no getent passwd $USERNAME | cut -d: -f6) local MNT_USER_HOME="/mnt${USER_HOME}" ln -sfT ${USER_SCRATCH} "${MNT_USER_HOME}/scratch" chown -h ${USERNAME}:${USERNAME} "${MNT_USER_HOME}/scratch" diff --git a/site/profile/templates/accounts/mkproject.sh.epp b/site/profile/templates/accounts/mkproject.sh.epp index 32a8862c5..226f452a6 100644 --- a/site/profile/templates/accounts/mkproject.sh.epp +++ b/site/profile/templates/accounts/mkproject.sh.epp @@ -48,13 +48,12 @@ while read CONN OP GROUP; do # We create the associated account in slurm /opt/software/slurm/bin/sacctmgr add account $GROUP -i <% if $with_folder { %> - # We clean the SSSD cache before recovering the group GID. - # This is in case the group existed before with a different gid. + # We ignore the SSSD cache before recovering the group GID. + # Using the cache would be problematic if the group existed before with a different gid. GID="" - sss_cache -g $GROUP while [ -z "$GID" ]; do sleep 5 - GID=$(getent group $GROUP | cut -d: -f3) + GID=$(SSS_NSS_USE_MEMCACHE=no getent group $GROUP | cut -d: -f3) done # Then we create the project folder @@ -103,7 +102,7 @@ while read CONN OP GROUP; do # If group has been modified but no uid were found in the log, it means # user(s) have been removed from the groups. # We identify which ones by comparing Slurm account with group. - USER_GROUP=$(sss_cache -g $GROUP && sleep 5 && getent group $GROUP | cut -d: -f4 | tr "," "\n" | sort) + USER_GROUP=$(sleep 5 && SSS_NSS_USE_MEMCACHE=no getent group $GROUP | cut -d: -f4 | tr "," "\n" | sort) SLURM_ACCOUNT=$(/opt/software/slurm/bin/sacctmgr list assoc account=$GROUP format=user --noheader -p | cut -d'|' -f1 | awk NF | sort) USERNAMES=$(comm -2 -3 <(echo "$SLURM_ACCOUNT") <(echo "$USER_GROUP")) if [[ ! -z "$USERNAMES" ]]; then