Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 16 additions & 4 deletions .github/workflows/test_eessi_container_script.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ jobs:
- listrepos_default
- listrepos_custom
- no_cvmfs_mounts
- exec
- run
- shell
- container
Expand Down Expand Up @@ -74,19 +75,30 @@ jobs:
# test use of --repository None
elif [[ ${{matrix.SCRIPT_TEST}} == 'no_cvmfs_mounts' ]]; then
outfile=out_nocvmfs.txt
./eessi_container.sh --verbose --repository None --mode run mount | tee ${outfile}
./eessi_container.sh --verbose --repository None --mode exec mount | tee ${outfile}
# make sure that there are no CVMFS mounts in the container, i.e. mount does not have any lines line:
# cvmfs2 on /cvmfs/...
! grep "^cvmfs" ${outfile}

# test use of --mode run
# test use of --mode exec
elif [[ ${{matrix.SCRIPT_TEST}} == 'exec' ]]; then
outfile=out_exec.txt
echo "${test_cmd}" > test_script.sh
chmod u+x test_script.sh
export SINGULARITY_BIND="$PWD:/test"
./eessi_container.sh --verbose --mode exec /test/test_script.sh | tee ${outfile}
grep "${out_pattern}" ${outfile}

# test use of --mode run, which should now print a warning
elif [[ ${{matrix.SCRIPT_TEST}} == 'run' ]]; then
outfile=out_run.txt
echo "${test_cmd}" > test_script.sh
chmod u+x test_script.sh
export SINGULARITY_BIND="$PWD:/test"
./eessi_container.sh --verbose --mode run /test/test_script.sh | tee ${outfile}
grep "${out_pattern}" ${outfile}
warn_message="Note: the behaviour of the run mode has changed."
grep "${warn_message}" ${outfile}

# test use of --mode shell
elif [[ ${{matrix.SCRIPT_TEST}} == 'shell' ]]; then
Expand All @@ -109,7 +121,7 @@ jobs:
echo "touch /cvmfs/software.eessi.io/${fn}" > test_script.sh
chmod u+x test_script.sh
export SINGULARITY_BIND="$PWD:/test"
./eessi_container.sh --verbose --access rw --mode run /test/test_script.sh > ${outfile}
./eessi_container.sh --verbose --access rw --mode exec /test/test_script.sh > ${outfile}

tmpdir=$(grep "\-\-resume" ${outfile} | sed "s/.*--resume \([^']*\).*/\1/g")
# note: must use '--access rw' again here, since touched file is in overlay upper dir
Expand Down Expand Up @@ -152,7 +164,7 @@ jobs:
export SINGULARITY_BIND="$PWD:/test"
echo 'ls -ld /cvmfs*/software.eessi.io/*' > test_script.sh
chmod u+x test_script.sh
./eessi_container.sh --verbose --container ${container} --access rw --overlay-tool unionfs --mode run /test/test_script.sh 2>&1 | tee ${outfile}
./eessi_container.sh --verbose --container ${container} --access rw --overlay-tool unionfs --mode exec /test/test_script.sh 2>&1 | tee ${outfile}
for pattern in "/cvmfs/software.eessi.io/versions" "/cvmfs_ro/software.eessi.io/versions"; do
grep "${pattern}" ${outfile} || (echo "Pattern '${pattern}' not found in ${outfile}"; exit 1)
done
Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/tests_scripts.yml
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ 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 /software-layer-scripts/eb-${EB_VERSION}.sh 2>&1 | tee ${out}
./eessi_container.sh --access rw --mode exec --verbose /software-layer-scripts/run_in_compat_layer_env.sh /software-layer-scripts/eb-${EB_VERSION}.sh 2>&1 | tee ${out}
pattern="^This is EasyBuild ${EB_VERSION} "
grep "${pattern}" ${out} || (echo "Pattern '${pattern}' not found in output!" && exit 1)
done
Expand All @@ -103,7 +103,7 @@ jobs:
# make sure that correct EESSI version is used (required because default is a placeholder version)
export EESSI_VERSION_OVERRIDE="${{matrix.EESSI_VERSION}}"

./eessi_container.sh --mode run --verbose /software-layer-scripts/install_software_layer.sh
./eessi_container.sh --mode exec --verbose /software-layer-scripts/install_software_layer.sh

- name: test create_directory_tarballs.sh script
run: |
Expand All @@ -116,7 +116,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 "${{matrix.EESSI_VERSION}}"
./eessi_container.sh --mode exec --verbose /software-layer-scripts/create_directory_tarballs.sh "${{matrix.EESSI_VERSION}}"
# check if tarballs have been produced
ls -l *.tar.gz

Expand All @@ -140,7 +140,7 @@ jobs:
export EESSI_VERSION_OVERRIDE="${{matrix.EESSI_VERSION}}"

out="${PWD}/test_create_lmodsitepackage.out"
./eessi_container.sh --mode run --verbose /software-layer-scripts/run_in_compat_layer_env.sh /software-layer-scripts/test_lmod_sitepackage.sh 2>&1 | tee ${out}
./eessi_container.sh --mode exec --verbose /software-layer-scripts/run_in_compat_layer_env.sh /software-layer-scripts/test_lmod_sitepackage.sh 2>&1 | tee ${out}
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
Expand All @@ -160,6 +160,6 @@ jobs:
export EESSI_VERSION_OVERRIDE="${{matrix.EESSI_VERSION}}"

out="${PWD}/eb-${EB_VERSION}.out"
./eessi_container.sh --repository software.eessi.io,access=rw,mount=bind --mode run --verbose /software-layer-scripts/run_in_compat_layer_env.sh ls 2>&1 | tee ${out}
./eessi_container.sh --repository software.eessi.io,access=rw,mount=bind --mode exec --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)
18 changes: 13 additions & 5 deletions eessi_container.sh
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ display_help() {
echo " [default: /..storage../opt-eessi]"
echo " -l | --list-repos - list available repository identifiers [default: false]"
echo " -m | --mode MODE - with MODE==shell (launch interactive shell) or"
echo " MODE==run (run a script or command) [default: shell]"
echo " MODE==exec/run (run a script or command) [default: shell]"
echo " -n | --nvidia MODE - configure the container to work with NVIDIA GPUs,"
echo " MODE==install for a CUDA installation, MODE==run to"
echo " attach a GPU, MODE==all for both [default: false]"
Expand Down Expand Up @@ -119,7 +119,7 @@ display_help() {
echo " -y | --https-proxy URL - provides URL for the env variable https_proxy"
echo " [default: not set]; uses env var \$https_proxy if set"
echo
echo " If value for --mode is 'run', the SCRIPT/COMMAND provided is executed. If"
echo " If value for --mode is 'exec' or 'run', the SCRIPT/COMMAND provided is executed. If"
echo " arguments to the script/command start with '-' or '--', use the flag terminator"
echo " '--' to let eessi_container.sh stop parsing arguments."
}
Expand Down Expand Up @@ -377,10 +377,18 @@ fi
# HOST_STORAGE_ERROR_EXITCODE

# (arg -m|--mode) check if MODE is known
if [[ "${MODE}" != "shell" && "${MODE}" != "run" ]]; then
if [[ "${MODE}" != "shell" && "${MODE}" != "exec" && "${MODE}" != "run" ]]; then
fatal_error "unknown execution mode '${MODE}'" "${MODE_UNKNOWN_EXITCODE}"
fi

# the run mode should actually call "apptainer exec", so simply override run to exec
if [[ "${MODE}" == "run" ]]; then
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should print some warning here that we've changed the behavior of this option to effectively exec. Even if we don't rely on any runscripts - and using run was effectively a mistake - this doesn't mean no one else used the eessi_container.sh with a runscript AND relied on its behaviour.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we should even introduce a mode force-run or something, which this warning may then suggest as an alternative (i.e. "if you really wanted the old behavior, use eessi_container.sh --mode force-run" (which we then remove at some point if we want to ever deprecate the run-to-exec fallback)?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed in 01aba0c. It now prints a warning message about the changed behaviour when --mode run is used, and it tells users to use --mode exec to silence that warning.

echo_yellow "Note: the behaviour of the run mode has changed."
echo_yellow "Previously, it mistakenly ran 'apptainer/singularity run', but it now runs 'apptainer/singularity exec' instead."
echo_yellow "You can silence this message by using --mode exec instead of --mode run."
MODE="exec"
fi

# Also validate the NVIDIA GPU mode (if present)
if [[ ${SETUP_NVIDIA} -eq 1 ]]; then
if [[ "${NVIDIA_MODE}" != "run" && "${NVIDIA_MODE}" != "install" && "${NVIDIA_MODE}" != "all" ]]; then
Expand Down Expand Up @@ -443,8 +451,8 @@ done
# TODO (arg -y|--https-proxy) check if https proxy is accessible
# HTTPS_PROXY_ERROR_EXITCODE

# check if a script is provided if mode is 'run'
if [[ "${MODE}" == "run" ]]; then
# check if a script is provided if mode is 'exec'
if [[ "${MODE}" == "exec" ]]; then
if [[ $# -eq 0 ]]; then
fatal_error "no command specified to run?!" "${RUN_SCRIPT_MISSING_EXITCODE}"
fi
Expand Down