Skip to content

Commit fabe658

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

File tree

2 files changed

+61
-21
lines changed

2 files changed

+61
-21
lines changed

create_tarball.sh

Lines changed: 15 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
@@ -32,6 +36,10 @@ fi
3236
cvmfs_repo_name=${cvmfs_repo%"/${EESSI_DEV_PROJECT}"}
3337
cvmfs_repo_name=${cvmfs_repo_name#/cvmfs/}
3438
overlay_upper_dir="${eessi_tmpdir}/${cvmfs_repo_name}/overlay-upper${EESSI_DEV_PROJECT:+/$EESSI_DEV_PROJECT}"
39+
# if unionfs overlay tool was used, we need to peek into .unionfs subdirectory
40+
if [ -d "${overlay_upper_dir}/.unionfs" ]; then
41+
overlay_upper_dir="${overlay_upper_dir}/.unionfs"
42+
fi
3543

3644
software_dir_overlay="${overlay_upper_dir}/versions/${eessi_version}"
3745
if [ ! -d ${software_dir_overlay} ]; then
@@ -49,30 +57,30 @@ module_files_list=${tmpdir}/module_files.list.txt
4957
if [ -d ${eessi_version}/software/${os}/${cpu_arch_subdir}/.lmod ]; then
5058
# include Lmod cache and configuration file (lmodrc.lua),
5159
# 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}
60+
find ${eessi_version}/software/${os}/${cpu_arch_subdir}/.lmod -type f | egrep -v "${REMOVED_FILES_PATTERN}|spiderT.old' >> ${files_list}
5361
fi
5462
5563
# include scripts that were copied by install_scripts.sh, which we want to ship in EESSI repository
5664
if [ -d ${eessi_version}/scripts ]; then
57-
find ${eessi_version}/scripts -type f | grep -v '/\.wh\.' >> ${files_list}
65+
find ${eessi_version}/scripts -type f | grep -v "${REMOVED_FILES_PATTERN}" >> ${files_list}
5866
fi
5967
6068
# also include init, which is also copied by install_scripts.sh
6169
if [ -d ${eessi_version}/init ]; then
62-
find ${eessi_version}/init -type f | grep -v '/\.wh\.' >> ${files_list}
70+
find ${eessi_version}/init -type f | grep -v "${REMOVED_FILES_PATTERN}" >> ${files_list}
6371
fi
6472
6573
# consider both CPU-only and accelerator subdirectories
6674
for subdir in ${cpu_arch_subdir} ${cpu_arch_subdir}/accel/${accel_subdir}; do
6775
6876
if [ -d ${eessi_version}/software/${os}/${subdir}/modules ]; then
6977
# 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
78+
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
7179
# 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
80+
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
7381
# module files and symlinks
7482
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 \
83+
| grep -v "${REMOVED_FILES_PATTERN}" | grep -v '/\.modulerc\.lua' | sed -e 's/.lua$//' | sed -e 's@.*/modules/all/@@g' | sort -u \
7684
>> ${module_files_list}
7785
fi
7886
@@ -86,7 +94,7 @@ for subdir in ${cpu_arch_subdir} ${cpu_arch_subdir}/accel/${accel_subdir}; do
8694
for package_version in $(cat ${module_files_list}); do
8795
echo "handling ${package_version}"
8896
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
97+
| 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
9098
done
9199
fi
92100
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)