Skip to content

Commit

Permalink
clean up lower dir changes
Browse files Browse the repository at this point in the history
  • Loading branch information
truib committed Nov 15, 2024
1 parent c7916ec commit 1c24b7a
Showing 1 changed file with 11 additions and 37 deletions.
48 changes: 11 additions & 37 deletions eessi_container.sh
Original file line number Diff line number Diff line change
Expand Up @@ -756,21 +756,9 @@ do
# to be able to see the contents of the read-write session we have to mount
# the fuse-overlayfs (in read-only mode) on top of the CernVM-FS repository

echo "While processing '${cvmfs_repo_name}' to be mounted 'read-only'"
echo " we detected one or more overlay-upper* directories"
echo " (${EESSI_TMPDIR}/${cvmfs_repo_name}/overlay-upper*)"
echo " likely originating from a previous session. Will use then as"
echo " left-most directory in 'lowerdir' argument for fuse-overlayfs."

lowerdirs=/cvmfs_ro/${cvmfs_repo_name}
# # check if there are more overlay-upper directories, e.g., with three digit suffix
# for dir in $(ls ${EESSI_TMPDIR}/${cvmfs_repo_name} | grep -E "overlay-upper-[0-9]{3}" | cut -f3 -d- | sort -n); do
# lowerdirs=${TMP_IN_CONTAINER}/${cvmfs_repo_name}/overlay-upper-${dir}:${lowerdirs}
# done
# finally add most recent overlay-upper to lowerdirs
lowerdirs=${TMP_IN_CONTAINER}/${cvmfs_repo_name}/overlay-upper:${lowerdirs}
[[ ${VERBOSE} -eq 1 ]] && ls ${EESSI_TMPDIR}/${cvmfs_repo_name}
[[ ${VERBOSE} -eq 1 ]] && echo ${lowerdirs}
echo "While processing '${cvmfs_repo_name}' to be mounted 'read-only' we detected an overlay-upper"
echo " directory (${EESSI_TMPDIR}/${cvmfs_repo_name}/overlay-upper) likely from a previous"
echo " session. Will use it as left-most directory in 'lowerdir' argument for fuse-overlayfs."

# make the target CernVM-FS repository available under /cvmfs_ro
export EESSI_READONLY="container:cvmfs2 ${cvmfs_repo_name} /cvmfs_ro/${cvmfs_repo_name}"
Expand All @@ -779,7 +767,12 @@ do

# now, put the overlay-upper read-only on top of the repo and make it available under the usual prefix /cvmfs
EESSI_READONLY_OVERLAY="container:fuse-overlayfs"
EESSI_READONLY_OVERLAY+=" -o lowerdir=${lowerdirs}"
# The contents of the previous session are available under
# ${EESSI_TMPDIR} which is bind mounted to ${TMP_IN_CONTAINER}.
# Hence, we have to use ${TMP_IN_CONTAINER}/${cvmfs_repo_name}/overlay-upper
# the left-most directory given for the lowerdir argument is put on top,
# and with no upperdir=... the whole overlayfs is made available read-only
EESSI_READONLY_OVERLAY+=" -o lowerdir=${TMP_IN_CONTAINER}/${cvmfs_repo_name}/overlay-upper:/cvmfs_ro/${cvmfs_repo_name}"
EESSI_READONLY_OVERLAY+=" /cvmfs/${cvmfs_repo_name}"
export EESSI_READONLY_OVERLAY

Expand All @@ -795,27 +788,7 @@ do
export EESSI_FUSE_MOUNTS
fi
elif [[ ${cvmfs_repo_access} == "rw" ]] ; then
# use repo-specific overlay directories; if there is already an
# overlay-upper (e.g., from a previous run) move it to overlay-upper-SEQ
# and create a new one; all overlay-upper-SEQs must be added to lowerdir
# starting with the lowest number first and preprending it to the lowerdir
# setting
lowerdirs=/cvmfs_ro/${cvmfs_repo_name}
# if [ -d ${EESSI_TMPDIR}/${cvmfs_repo_name}/overlay-upper ]; then
# # determine next sequence number
# last_seq_num=$(ls ${EESSI_TMPDIR}/${cvmfs_repo_name} | grep -E "overlay-upper-[0-9]{3}" | cut -f3 -d- | sort -n | tail -n 1 | sed -e 's/^0*//')
# if [ -n ${last_seq_num} ]; then
# last_seq_num=0
# fi
# next_seq_num=$(($last_seq_num + 1))
# next_ovl_upper=$(printf "overlay-upper-%03d" ${next_seq_num})
# mv ${EESSI_TMPDIR}/${cvmfs_repo_name}/overlay-upper ${EESSI_TMPDIR}/${cvmfs_repo_name}/${next_ovl_upper}
# for dir in $(ls ${EESSI_TMPDIR}/${cvmfs_repo_name} | grep -E "overlay-upper-[0-9]{3}" | cut -f3 -d- | sort -n); do
# lowerdirs=${TMP_IN_CONTAINER}/${cvmfs_repo_name}/overlay-upper-${dir}:${lowerdirs}
# done
# [[ ${VERBOSE} -eq 1 ]] && ls ${EESSI_TMPDIR}/${cvmfs_repo_name}
# [[ ${VERBOSE} -eq 1 ]] && echo ${lowerdirs}
# fi
# use repo-specific overlay directories
mkdir -p ${EESSI_TMPDIR}/${cvmfs_repo_name}/overlay-upper
mkdir -p ${EESSI_TMPDIR}/${cvmfs_repo_name}/overlay-work
[[ ${VERBOSE} -eq 1 ]] && echo -e "TMP directory contents:\n$(ls -l ${EESSI_TMPDIR})"
Expand All @@ -826,6 +799,7 @@ do
EESSI_FUSE_MOUNTS+=("--fusemount" "${EESSI_READONLY}")

EESSI_WRITABLE_OVERLAY="container:fuse-overlayfs"
lowerdirs=/cvmfs_ro/${cvmfs_repo_name}
if [[ ! -z ${LOWER_DIRS} ]]; then
# need to convert ':' in LOWER_DIRS to ',' because bind mounts use ',' as
# separator while the lowerdir overlayfs option uses ':'
Expand Down

0 comments on commit 1c24b7a

Please sign in to comment.