From 4f5b315b94e39c30810c210182ea0314d14fb261 Mon Sep 17 00:00:00 2001 From: Alan O'Cais Date: Fri, 1 Aug 2025 14:30:48 +0200 Subject: [PATCH 1/8] Use the system cvmfs repositories if they are available --- eessi_container.sh | 46 ++++++++++++++++++++++++++++++++++------------ 1 file changed, 34 insertions(+), 12 deletions(-) diff --git a/eessi_container.sh b/eessi_container.sh index 00a03227..c0be36fc 100755 --- a/eessi_container.sh +++ b/eessi_container.sh @@ -747,7 +747,14 @@ declare -a EESSI_FUSE_MOUNTS=() # mount cvmfs-config repo (to get access to EESSI repositories such as software.eessi.io) unless env var # EESSI_DO_NOT_MOUNT_CVMFS_CONFIG_CERN_CH is defined if [ -z ${EESSI_DO_NOT_MOUNT_CVMFS_CONFIG_CERN_CH+x} ]; then - EESSI_FUSE_MOUNTS+=("--fusemount" "container:cvmfs2 cvmfs-config.cern.ch /cvmfs/cvmfs-config.cern.ch") + if cvmfs_config stat cvmfs-config.cern.ch ; then + # if the system has the repo available just pass it through + BIND_PATHS="${BIND_PATHS},/cvmfs/cvmfs-config.cern.ch:/cvmfs/cvmfs-config.cern.ch" + else + # otherwise use apptainer capabilities to make it available within the container + EESSI_FUSE_MOUNTS+=("--fusemount" "container:cvmfs2 cvmfs-config.cern.ch /cvmfs/cvmfs-config.cern.ch") + export EESSI_FUSE_MOUNTS + fi fi @@ -795,9 +802,14 @@ do 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}" - - EESSI_FUSE_MOUNTS+=("--fusemount" "${EESSI_READONLY}") + if cvmfs_config stat ${cvmfs_repo_name} ; then + # if the system has the repo available just pass it through + BIND_PATHS="${BIND_PATHS},/cvmfs/${cvmfs_repo_name}:/cvmfs_ro/${cvmfs_repo_name}" + else + # otherwise use apptainer capabilities to make it available within the container + export EESSI_READONLY="container:cvmfs2 ${cvmfs_repo_name} /cvmfs_ro/${cvmfs_repo_name}" + EESSI_FUSE_MOUNTS+=("--fusemount" "${EESSI_READONLY}") + fi # now, put the overlay-upper read-only on top of the repo and make it available under the usual prefix /cvmfs if [[ "${OVERLAY_TOOL}" == "fuse-overlayfs" ]]; then @@ -827,10 +839,15 @@ do # basic "ro" access that doesn't require any fuseoverlay-fs echo "Mounting '${cvmfs_repo_name}' 'read-only' without fuse-overlayfs." - export EESSI_READONLY="container:cvmfs2 ${cvmfs_repo_name} /cvmfs/${cvmfs_repo_name}" - - EESSI_FUSE_MOUNTS+=("--fusemount" "${EESSI_READONLY}") - export EESSI_FUSE_MOUNTS + if cvmfs_config stat ${cvmfs_repo_name} ; then + # if the system has the repo available just pass it through + BIND_PATHS="${BIND_PATHS},/cvmfs/${cvmfs_repo_name}:/cvmfs/${cvmfs_repo_name}" + else + # otherwise use apptainer capabilities to make it available within the container + export EESSI_READONLY="container:cvmfs2 ${cvmfs_repo_name} /cvmfs/${cvmfs_repo_name}" + EESSI_FUSE_MOUNTS+=("--fusemount" "${EESSI_READONLY}") + export EESSI_FUSE_MOUNTS + fi fi elif [[ ${cvmfs_repo_access} == "rw" ]] ; then # use repo-specific overlay directories @@ -839,10 +856,15 @@ do [[ ${VERBOSE} -eq 1 ]] && echo -e "TMP directory contents:\n$(ls -l ${EESSI_TMPDIR})" - # set environment variables for fuse mounts in Singularity container - export EESSI_READONLY="container:cvmfs2 ${cvmfs_repo_name} /cvmfs_ro/${cvmfs_repo_name}" - - EESSI_FUSE_MOUNTS+=("--fusemount" "${EESSI_READONLY}") + # make the target CernVM-FS repository available under /cvmfs_ro + if cvmfs_config stat ${cvmfs_repo_name} ; then + # if the system has the repo available just pass it through + BIND_PATHS="${BIND_PATHS},/cvmfs/${cvmfs_repo_name}:/cvmfs_ro/${cvmfs_repo_name}" + else + # otherwise use apptainer capabilities to make it available within the container + export EESSI_READONLY="container:cvmfs2 ${cvmfs_repo_name} /cvmfs_ro/${cvmfs_repo_name}" + EESSI_FUSE_MOUNTS+=("--fusemount" "${EESSI_READONLY}") + fi if [[ "${OVERLAY_TOOL}" == "fuse-overlayfs" ]]; then EESSI_WRITABLE_OVERLAY="container:fuse-overlayfs" From a62606d0a10a01a27f3f0a697d40509bcc3abec4 Mon Sep 17 00:00:00 2001 From: Alan O'Cais Date: Fri, 1 Aug 2025 14:50:34 +0200 Subject: [PATCH 2/8] Add a test to ensure that we can bind moount repos if they are available --- .github/workflows/tests_scripts.yml | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/.github/workflows/tests_scripts.yml b/.github/workflows/tests_scripts.yml index 9fd6421c..db04d4b9 100644 --- a/.github/workflows/tests_scripts.yml +++ b/.github/workflows/tests_scripts.yml @@ -41,7 +41,7 @@ jobs: - name: install Apptainer run: | ./install_apptainer_ubuntu.sh - + - name: test load_easybuild_module.sh script run: | # bind current directory into container as /software-layer-scripts @@ -139,3 +139,16 @@ jobs: for pattern in "^Site Pkg location.*/software-layer-scripts/.lmod/SitePackage.lua" "LMOD_SITEPACKAGE_LOCATION.*/software-layer-scripts/.lmod/SitePackage.lua"; do grep "${pattern}" ${out} || (echo "Pattern '${pattern}' not found in output!" && exit 1) done + + - name: Mount EESSI CernVM-FS repository + uses: eessi/github-action-eessi@v3 + with: + eessi_stack_version: ${{matrix.EESSI_VERSION}} + use_eessi_module: true + + - name: Verify that mounted repositories are passed through directly + run: | + # run wrapper script + capture & check output + out="${PWD}/eb-${EB_VERSION}.out" + ./eessi_container.sh --access rw --mode run --verbose /software-layer-scripts/run_in_compat_layer_env.sh ls 2>&1 | tee ${out} + grep "SINGULARITY_BIND" ${out} | grep "software.eessi.io" || (echo "software.eessi.io did not seem to be bind mounted!" && exit 1) From 744a24c7c3686bfb5b3e89018c176568e7b0819a Mon Sep 17 00:00:00 2001 From: Alan O'Cais Date: Fri, 1 Aug 2025 14:53:43 +0200 Subject: [PATCH 3/8] Fix CI --- .github/workflows/tests_scripts.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/tests_scripts.yml b/.github/workflows/tests_scripts.yml index db04d4b9..80ba7191 100644 --- a/.github/workflows/tests_scripts.yml +++ b/.github/workflows/tests_scripts.yml @@ -50,7 +50,7 @@ jobs: # can't test with EasyBuild versions older than v4.5.2 when using EESSI 2023.06, # since Python in compat layer is Python 3.11.x; # testing with a single EasyBuild version takes a while in GitHub Actions, so stick to a single sensible version - for EB_VERSION in '4.6.0'; do + for EB_VERSION in '5.1.0'; do # Create script that uses load_easybuild_module.sh which we can run in compat layer environment # note: Be careful with single vs double quotes below! # ${EB_VERSION} should be expanded, so use double quotes; @@ -112,7 +112,7 @@ jobs: # scripts need to be copied to /tmp, # since create_directory_tarballs.sh must be accessible from within build container - ./eessi_container.sh --mode run --verbose /software-layer-scripts/create_directory_tarballs.sh 2023.06 + ./eessi_container.sh --mode run --verbose /software-layer-scripts/create_directory_tarballs.sh "${{matrix.EESSI_VERSION}}" # check if tarballs have been produced ls -l *.tar.gz From 3567740e928843a9d813ce7a51480c30a5b792d2 Mon Sep 17 00:00:00 2001 From: Alan O'Cais Date: Fri, 1 Aug 2025 14:55:53 +0200 Subject: [PATCH 4/8] PRint based debugging because I am such a good programmer --- .github/workflows/tests_scripts.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/tests_scripts.yml b/.github/workflows/tests_scripts.yml index 35980180..8fb32dcf 100644 --- a/.github/workflows/tests_scripts.yml +++ b/.github/workflows/tests_scripts.yml @@ -152,4 +152,5 @@ jobs: # run wrapper script + capture & check output out="${PWD}/eb-${EB_VERSION}.out" ./eessi_container.sh --access rw --mode run --verbose /software-layer-scripts/run_in_compat_layer_env.sh ls 2>&1 | tee ${out} + echo $(grep "SINGULARITY_BIND" ${out}) grep "SINGULARITY_BIND" ${out} | grep "software.eessi.io" || (echo "software.eessi.io did not seem to be bind mounted!" && exit 1) From 3d82dd93107be0627a8c927fb2ea304f3f7dcc2e Mon Sep 17 00:00:00 2001 From: Alan O'Cais Date: Fri, 1 Aug 2025 15:11:35 +0200 Subject: [PATCH 5/8] Reuse temp space --- .github/workflows/tests_scripts.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/workflows/tests_scripts.yml b/.github/workflows/tests_scripts.yml index 8fb32dcf..9a6d9a8f 100644 --- a/.github/workflows/tests_scripts.yml +++ b/.github/workflows/tests_scripts.yml @@ -45,6 +45,7 @@ jobs: - name: test load_easybuild_module.sh script run: | + export TMPDIR=$PWD # bind current directory into container as /software-layer-scripts export SINGULARITY_BIND="${PWD}:/software-layer-scripts" @@ -91,6 +92,7 @@ jobs: - name: test install_software_layer.sh script run: | + export TMPDIR=$PWD # bind current directory into container as /software-layer-scripts export SINGULARITY_BIND="${PWD}:/software-layer-scripts" # force using x86_64/generic, to avoid triggering an installation from scratch @@ -105,6 +107,7 @@ jobs: - name: test create_directory_tarballs.sh script run: | + export TMPDIR=$PWD # bind current directory into container as /software-layer-scripts export SINGULARITY_BIND="${PWD}:/software-layer-scripts" @@ -119,6 +122,7 @@ jobs: - name: test create_lmodsitepackage.py script run: | + export TMPDIR=$PWD # bind current directory into container as /software-layer-scripts export SINGULARITY_BIND="${PWD}:/software-layer-scripts" @@ -149,7 +153,9 @@ jobs: - name: Verify that mounted repositories are passed through directly run: | + export TMPDIR=$PWD # run wrapper script + capture & check output + export SINGULARITY_BIND="${PWD}:/software-layer-scripts" out="${PWD}/eb-${EB_VERSION}.out" ./eessi_container.sh --access rw --mode run --verbose /software-layer-scripts/run_in_compat_layer_env.sh ls 2>&1 | tee ${out} echo $(grep "SINGULARITY_BIND" ${out}) From 36ce78d18a3e9fddf034bbc7947040c1520c6bee Mon Sep 17 00:00:00 2001 From: Alan O'Cais Date: Fri, 1 Aug 2025 15:12:48 +0200 Subject: [PATCH 6/8] Lint myself --- .github/workflows/tests_scripts.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/tests_scripts.yml b/.github/workflows/tests_scripts.yml index 9a6d9a8f..3588a2ed 100644 --- a/.github/workflows/tests_scripts.yml +++ b/.github/workflows/tests_scripts.yml @@ -42,7 +42,7 @@ jobs: - name: install Apptainer run: | ./install_apptainer_ubuntu.sh - + - name: test load_easybuild_module.sh script run: | export TMPDIR=$PWD From b948015198174612ada2a41579dc8ebd138291bf Mon Sep 17 00:00:00 2001 From: Alan O'Cais Date: Fri, 1 Aug 2025 15:20:15 +0200 Subject: [PATCH 7/8] Use SINGULARITY_CACHEDIR explicitly --- .github/workflows/tests_scripts.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/tests_scripts.yml b/.github/workflows/tests_scripts.yml index 3588a2ed..089c97a7 100644 --- a/.github/workflows/tests_scripts.yml +++ b/.github/workflows/tests_scripts.yml @@ -45,7 +45,7 @@ jobs: - name: test load_easybuild_module.sh script run: | - export TMPDIR=$PWD + export SINGULARITY_CACHEDIR=$PWD # bind current directory into container as /software-layer-scripts export SINGULARITY_BIND="${PWD}:/software-layer-scripts" @@ -92,7 +92,7 @@ jobs: - name: test install_software_layer.sh script run: | - export TMPDIR=$PWD + export SINGULARITY_CACHEDIR=$PWD # bind current directory into container as /software-layer-scripts export SINGULARITY_BIND="${PWD}:/software-layer-scripts" # force using x86_64/generic, to avoid triggering an installation from scratch @@ -107,7 +107,7 @@ jobs: - name: test create_directory_tarballs.sh script run: | - export TMPDIR=$PWD + export SINGULARITY_CACHEDIR=$PWD # bind current directory into container as /software-layer-scripts export SINGULARITY_BIND="${PWD}:/software-layer-scripts" @@ -122,7 +122,7 @@ jobs: - name: test create_lmodsitepackage.py script run: | - export TMPDIR=$PWD + export SINGULARITY_CACHEDIR=$PWD # bind current directory into container as /software-layer-scripts export SINGULARITY_BIND="${PWD}:/software-layer-scripts" @@ -153,7 +153,7 @@ jobs: - name: Verify that mounted repositories are passed through directly run: | - export TMPDIR=$PWD + export SINGULARITY_CACHEDIR=$PWD # run wrapper script + capture & check output export SINGULARITY_BIND="${PWD}:/software-layer-scripts" out="${PWD}/eb-${EB_VERSION}.out" From 83c9378b3869b4cf6f356aaf1117b5e9fff0c8dc Mon Sep 17 00:00:00 2001 From: Alan O'Cais Date: Fri, 1 Aug 2025 15:45:20 +0200 Subject: [PATCH 8/8] Fix another small issue --- .github/workflows/tests_scripts.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/tests_scripts.yml b/.github/workflows/tests_scripts.yml index 089c97a7..2875cb2e 100644 --- a/.github/workflows/tests_scripts.yml +++ b/.github/workflows/tests_scripts.yml @@ -156,6 +156,9 @@ jobs: export SINGULARITY_CACHEDIR=$PWD # run wrapper script + capture & check output export SINGULARITY_BIND="${PWD}:/software-layer-scripts" + # make sure that correct EESSI version is used (required because default is a placeholder version) + export EESSI_VERSION_OVERRIDE="${{matrix.EESSI_VERSION}}" + out="${PWD}/eb-${EB_VERSION}.out" ./eessi_container.sh --access rw --mode run --verbose /software-layer-scripts/run_in_compat_layer_env.sh ls 2>&1 | tee ${out} echo $(grep "SINGULARITY_BIND" ${out})