Skip to content

Commit

Permalink
Use SSS_NSS_USE_MEMCACHE=no instead of sss_cache invalidation
Browse files Browse the repository at this point in the history
  • Loading branch information
cmd-ntrf committed Oct 24, 2023
1 parent def1ca0 commit ff2a6f4
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 9 deletions.
7 changes: 3 additions & 4 deletions site/profile/files/accounts/account_functions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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}
Expand Down Expand Up @@ -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"
Expand Down
9 changes: 4 additions & 5 deletions site/profile/templates/accounts/mkproject.sh.epp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit ff2a6f4

Please sign in to comment.