Skip to content

Commit ce25257

Browse files
committed
add support to eessi_container.sh and create_tarball.sh for using unionfs overlay tool
1 parent a621ae5 commit ce25257

File tree

2 files changed

+57
-21
lines changed

2 files changed

+57
-21
lines changed

create_tarball.sh

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33
set -e
44

5+
# with fuse-overlayfs as overlay tool, removed files are indicated with .wh.*
6+
# with unionfs as overlay tool, removed files are indicated with *_HIDDEN~
7+
REMOVED_FILES_PATTERN='/\.wh\.|/[^/]*_HIDDEN\~'
8+
59
base_dir=$(dirname $(realpath $0))
610

711
if [ $# -ne 5 ]; then
@@ -49,30 +53,30 @@ module_files_list=${tmpdir}/module_files.list.txt
4953
if [ -d ${eessi_version}/software/${os}/${cpu_arch_subdir}/.lmod ]; then
5054
# include Lmod cache and configuration file (lmodrc.lua),
5155
# skip whiteout files and backup copies of Lmod cache (spiderT.old.*)
52-
find ${eessi_version}/software/${os}/${cpu_arch_subdir}/.lmod -type f | egrep -v '/\.wh\.|spiderT.old' >> ${files_list}
56+
find ${eessi_version}/software/${os}/${cpu_arch_subdir}/.lmod -type f | egrep -v "${REMOVED_FILES_PATTERN}|spiderT.old" >> ${files_list}
5357
fi
5458

5559
# include scripts that were copied by install_scripts.sh, which we want to ship in EESSI repository
5660
if [ -d ${eessi_version}/scripts ]; then
57-
find ${eessi_version}/scripts -type f | grep -v '/\.wh\.' >> ${files_list}
61+
find ${eessi_version}/scripts -type f | grep -v "${REMOVED_FILES_PATTERN}" >> ${files_list}
5862
fi
5963

6064
# also include init, which is also copied by install_scripts.sh
6165
if [ -d ${eessi_version}/init ]; then
62-
find ${eessi_version}/init -type f | grep -v '/\.wh\.' >> ${files_list}
66+
find ${eessi_version}/init -type f | grep -v "${REMOVED_FILES_PATTERN}" >> ${files_list}
6367
fi
6468

6569
# consider both CPU-only and accelerator subdirectories
6670
for subdir in ${cpu_arch_subdir} ${cpu_arch_subdir}/accel/${accel_subdir}; do
6771

6872
if [ -d ${eessi_version}/software/${os}/${subdir}/modules ]; then
6973
# module files
70-
find ${eessi_version}/software/${os}/${subdir}/modules -type f | grep -v '/\.wh\.' >> ${files_list} || true # Make sure we don't exit because of set -e if grep doesn't return a match
74+
find ${eessi_version}/software/${os}/${subdir}/modules -type f | grep -v "${REMOVED_FILES_PATTERN}" >> ${files_list} || true # Make sure we don't exit because of set -e if grep doesn't return a match
7175
# module symlinks
72-
find ${eessi_version}/software/${os}/${subdir}/modules -type l | grep -v '/\.wh\.' >> ${files_list} || true # Make sure we don't exit because of set -e if grep doesn't return a match
76+
find ${eessi_version}/software/${os}/${subdir}/modules -type l | grep -v "${REMOVED_FILES_PATTERN}" >> ${files_list} || true # Make sure we don't exit because of set -e if grep doesn't return a match
7377
# module files and symlinks
7478
find ${eessi_version}/software/${os}/${subdir}/modules/all -type f -o -type l \
75-
| grep -v '/\.wh\.' | grep -v '/\.modulerc\.lua' | sed -e 's/.lua$//' | sed -e 's@.*/modules/all/@@g' | sort -u \
79+
| grep -v "${REMOVED_FILES_PATTERN}" | grep -v '/\.modulerc\.lua' | sed -e 's/.lua$//' | sed -e 's@.*/modules/all/@@g' | sort -u \
7680
>> ${module_files_list}
7781
fi
7882

@@ -86,7 +90,7 @@ for subdir in ${cpu_arch_subdir} ${cpu_arch_subdir}/accel/${accel_subdir}; do
8690
for package_version in $(cat ${module_files_list}); do
8791
echo "handling ${package_version}"
8892
ls -d ${eessi_version}/software/${os}/${subdir}/software/${package_version} \
89-
| grep -v '/\.wh\.' >> ${files_list} || true # Make sure we don't exit because of set -e if grep doesn't return a match
93+
| grep -v "${REMOVED_FILES_PATTERN}" >> ${files_list} || true # Make sure we don't exit because of set -e if grep doesn't return a match
9094
done
9195
fi
9296
done

eessi_container.sh

Lines changed: 46 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ HTTP_PROXY_ERROR_EXITCODE=$((${ANY_ERROR_EXITCODE} << 9))
4747
HTTPS_PROXY_ERROR_EXITCODE=$((${ANY_ERROR_EXITCODE} << 10))
4848
RUN_SCRIPT_MISSING_EXITCODE=$((${ANY_ERROR_EXITCODE} << 11))
4949
NVIDIA_MODE_UNKNOWN_EXITCODE=$((${ANY_ERROR_EXITCODE} << 12))
50+
OVERLAY_TOOL_EXITCODE=$((${ANY_ERROR_EXITCODE} << 13))
5051

5152
# CernVM-FS settings
5253
CVMFS_VAR_LIB="var-lib-cvmfs"
@@ -89,6 +90,9 @@ display_help() {
8990
echo " -n | --nvidia MODE - configure the container to work with NVIDIA GPUs,"
9091
echo " MODE==install for a CUDA installation, MODE==run to"
9192
echo " attach a GPU, MODE==all for both [default: false]"
93+
echo " -o | --overlay-tool ARG - tool to use to create (read-only or writable) overlay;"
94+
echo " selected tool *must* be available in container image being used;"
95+
echo " can be 'fuse-overlayfs' or 'unionfs' [default: fuse-overlayfs]"
9296
echo " -p | --pass-through ARG - argument to pass through to the launch of the"
9397
echo " container; can be given multiple times [default: not set]"
9498
echo " -r | --repository CFG - configuration file or identifier defining the"
@@ -128,6 +132,7 @@ VERBOSE=0
128132
STORAGE=
129133
LIST_REPOS=0
130134
MODE="shell"
135+
OVERLAY_TOOL="fuse-overlayfs"
131136
PASS_THROUGH=()
132137
SETUP_NVIDIA=0
133138
REPOSITORIES=()
@@ -185,6 +190,10 @@ while [[ $# -gt 0 ]]; do
185190
NVIDIA_MODE="$2"
186191
shift 2
187192
;;
193+
-o|--overlay-tool)
194+
OVERLAY_TOOL="$2"
195+
shift 2
196+
;;
188197
-p|--pass-through)
189198
PASS_THROUGH+=("$2")
190199
shift 2
@@ -779,7 +788,7 @@ do
779788
# below); the overlay-upper directory can only exist because it is part of
780789
# the ${RESUME} directory or tarball
781790
# to be able to see the contents of the read-write session we have to mount
782-
# the fuse-overlayfs (in read-only mode) on top of the CernVM-FS repository
791+
# the overlay (in read-only mode) on top of the CernVM-FS repository
783792

784793
echo "While processing '${cvmfs_repo_name}' to be mounted 'read-only' we detected an overlay-upper"
785794
echo " directory (${EESSI_TMPDIR}/${cvmfs_repo_name}/overlay-upper) likely from a previous"
@@ -791,14 +800,25 @@ do
791800
EESSI_FUSE_MOUNTS+=("--fusemount" "${EESSI_READONLY}")
792801

793802
# now, put the overlay-upper read-only on top of the repo and make it available under the usual prefix /cvmfs
794-
EESSI_READONLY_OVERLAY="container:fuse-overlayfs"
795-
# The contents of the previous session are available under
796-
# ${EESSI_TMPDIR} which is bind mounted to ${TMP_IN_CONTAINER}.
797-
# Hence, we have to use ${TMP_IN_CONTAINER}/${cvmfs_repo_name}/overlay-upper
798-
# the left-most directory given for the lowerdir argument is put on top,
799-
# and with no upperdir=... the whole overlayfs is made available read-only
800-
EESSI_READONLY_OVERLAY+=" -o lowerdir=${TMP_IN_CONTAINER}/${cvmfs_repo_name}/overlay-upper:/cvmfs_ro/${cvmfs_repo_name}"
801-
EESSI_READONLY_OVERLAY+=" /cvmfs/${cvmfs_repo_name}"
803+
if [[ "${OVERLAY_TOOL}" == "fuse-overlayfs" ]]; then
804+
EESSI_READONLY_OVERLAY="container:fuse-overlayfs"
805+
# The contents of the previous session are available under
806+
# ${EESSI_TMPDIR} which is bind mounted to ${TMP_IN_CONTAINER}.
807+
# Hence, we have to use ${TMP_IN_CONTAINER}/${cvmfs_repo_name}/overlay-upper
808+
# the left-most directory given for the lowerdir argument is put on top,
809+
# and with no upperdir=... the whole overlayfs is made available read-only
810+
EESSI_READONLY_OVERLAY+=" -o lowerdir=${TMP_IN_CONTAINER}/${cvmfs_repo_name}/overlay-upper:/cvmfs_ro/${cvmfs_repo_name}"
811+
EESSI_READONLY_OVERLAY+=" /cvmfs/${cvmfs_repo_name}"
812+
elif [[ "${OVERLAY_TOOL}" == "unionfs" ]]; then
813+
EESSI_READONLY_OVERLAY="container:unionfs"
814+
# cow stands for 'copy-on-write'
815+
EESSI_READONLY_OVERLAY+=" -o cow"
816+
EESSI_READONLY_OVERLAY+=" /cvmfs_ro/software.eessi.io=RO"
817+
EESSI_READONLY_OVERLAY+=" /cvmfs/${cvmfs_repo_name}"
818+
else
819+
echo -e "ERROR: unknown overlay tool specified: ${OVERLAY_TOOL}"
820+
exit ${OVERLAY_TOOL_EXITCODE}
821+
fi
802822
export EESSI_READONLY_OVERLAY
803823

804824
EESSI_FUSE_MOUNTS+=("--fusemount" "${EESSI_READONLY_OVERLAY}")
@@ -824,11 +844,23 @@ do
824844

825845
EESSI_FUSE_MOUNTS+=("--fusemount" "${EESSI_READONLY}")
826846

827-
EESSI_WRITABLE_OVERLAY="container:fuse-overlayfs"
828-
EESSI_WRITABLE_OVERLAY+=" -o lowerdir=/cvmfs_ro/${cvmfs_repo_name}"
829-
EESSI_WRITABLE_OVERLAY+=" -o upperdir=${TMP_IN_CONTAINER}/${cvmfs_repo_name}/overlay-upper"
830-
EESSI_WRITABLE_OVERLAY+=" -o workdir=${TMP_IN_CONTAINER}/${cvmfs_repo_name}/overlay-work"
831-
EESSI_WRITABLE_OVERLAY+=" /cvmfs/${cvmfs_repo_name}"
847+
if [[ "${OVERLAY_TOOL}" == "fuse-overlayfs" ]]; then
848+
EESSI_WRITABLE_OVERLAY="container:fuse-overlayfs"
849+
EESSI_WRITABLE_OVERLAY+=" -o lowerdir=/cvmfs_ro/${cvmfs_repo_name}"
850+
EESSI_WRITABLE_OVERLAY+=" -o upperdir=${TMP_IN_CONTAINER}/${cvmfs_repo_name}/overlay-upper"
851+
EESSI_WRITABLE_OVERLAY+=" -o workdir=${TMP_IN_CONTAINER}/${cvmfs_repo_name}/overlay-work"
852+
EESSI_WRITABLE_OVERLAY+=" /cvmfs/${cvmfs_repo_name}"
853+
elif [[ "${OVERLAY_TOOL}" == "unionfs" ]]; then
854+
# files touched are reflected under /cvmfs/<repo>/.unionfs/
855+
EESSI_WRITABLE_OVERLAY="container:unionfs"
856+
# cow stands for 'copy-on-write'
857+
EESSI_WRITABLE_OVERLAY+=" -o cow"
858+
EESSI_WRITABLE_OVERLAY+=" ${TMP_IN_CONTAINER}/${cvmfs_repo_name}/overlay-upper=RW:/cvmfs_ro/software.eessi.io=RO"
859+
EESSI_WRITABLE_OVERLAY+=" /cvmfs/${cvmfs_repo_name}"
860+
else
861+
echo -e "ERROR: unknown overlay tool specified: ${OVERLAY_TOOL}"
862+
exit ${OVERLAY_TOOL_EXITCODE}
863+
fi
832864
export EESSI_WRITABLE_OVERLAY
833865

834866
EESSI_FUSE_MOUNTS+=("--fusemount" "${EESSI_WRITABLE_OVERLAY}")

0 commit comments

Comments
 (0)