From 70c1b146789d3d0c4d92f0a368ab078c724b898a Mon Sep 17 00:00:00 2001 From: Caspar van Leeuwen Date: Thu, 13 Jun 2024 15:18:17 +0200 Subject: [PATCH 1/4] Make sure we bind-mount /sys/fs/cgroup into the container, so that we can use it to determine available memory for dynamically configuring ReFrame in the test step --- bot/test.sh | 3 ++ eessi_container.sh | 78 ++++++++++++++++++++++++++-------------------- test_suite.sh | 2 +- 3 files changed, 48 insertions(+), 35 deletions(-) diff --git a/bot/test.sh b/bot/test.sh index 4984340e6e..b3f6acf0ea 100755 --- a/bot/test.sh +++ b/bot/test.sh @@ -204,6 +204,9 @@ if [[ -z ${RESUME_DIR} ]]; then else TEST_STEP_ARGS+=("--resume" "${RESUME_DIR}") fi +# Bind mount /sys/fs/cgroup so that we can determine the amount of memory available in our cgroup for +# Reframe configuration +TEST_STEP_ARGS+=("--extra-bind-paths /sys/fs/cgroup:/hostsys/fs/cgroup:ro") # prepare arguments to test_suite.sh (specific to test step) declare -a TEST_SUITE_ARGS=() diff --git a/eessi_container.sh b/eessi_container.sh index a95a2c87c9..eac8e74c83 100755 --- a/eessi_container.sh +++ b/eessi_container.sh @@ -70,40 +70,43 @@ export EESSI_REPOS_CFG_FILE="${EESSI_REPOS_CFG_DIR}/repos.cfg" display_help() { echo "usage: $0 [OPTIONS] [[--] SCRIPT or COMMAND]" echo " OPTIONS:" - echo " -a | --access {ro,rw} - ro (read-only), rw (read & write) [default: ro]" - echo " -c | --container IMG - image file or URL defining the container to use" - echo " [default: docker://ghcr.io/eessi/build-node:debian11]" - echo " -f | --fakeroot - run the container with --fakeroot [default: false]" - echo " -g | --storage DIR - directory space on host machine (used for" - echo " temporary data) [default: 1. TMPDIR, 2. /tmp]" - echo " -h | --help - display this usage information [default: false]" - echo " -i | --host-injections - directory to link to for host_injections " - 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 " -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]" - echo " -r | --repository CFG - configuration file or identifier defining the" - echo " repository to use [default: EESSI via" - echo " default container, see --container]" - echo " -u | --resume DIR/TGZ - resume a previous run from a directory or tarball," - echo " where DIR points to a previously used tmp directory" - echo " (check for output 'Using DIR as tmp ...' of a previous" - echo " run) and TGZ is the path to a tarball which is" - echo " unpacked the tmp dir stored on the local storage space" - echo " (see option --storage above) [default: not set]" - echo " -s | --save DIR/TGZ - save contents of tmp directory to a tarball in" - echo " directory DIR or provided with the fixed full path TGZ" - echo " when a directory is provided, the format of the" - echo " tarball's name will be {REPO_ID}-{TIMESTAMP}.tgz" - echo " [default: not set]" - echo " -v | --verbose - display more information [default: false]" - echo " -x | --http-proxy URL - provides URL for the env variable http_proxy" - echo " [default: not set]; uses env var \$http_proxy if set" - 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 " -a | --access {ro,rw} - ro (read-only), rw (read & write) [default: ro]" + echo " -c | --container IMG - image file or URL defining the container to use" + echo " [default: docker://ghcr.io/eessi/build-node:debian11]" + echo " -f | --fakeroot - run the container with --fakeroot [default: false]" + echo " -g | --storage DIR - directory space on host machine (used for" + echo " temporary data) [default: 1. TMPDIR, 2. /tmp]" + echo " -h | --help - display this usage information [default: false]" + echo " -i | --host-injections - directory to link to for host_injections " + 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 " -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]" + echo " -r | --repository CFG - configuration file or identifier defining the" + echo " repository to use [default: EESSI via" + echo " default container, see --container]" + echo " -u | --resume DIR/TGZ - resume a previous run from a directory or tarball," + echo " where DIR points to a previously used tmp directory" + echo " (check for output 'Using DIR as tmp ...' of a previous" + echo " run) and TGZ is the path to a tarball which is" + echo " unpacked the tmp dir stored on the local storage space" + echo " (see option --storage above) [default: not set]" + echo " -s | --save DIR/TGZ - save contents of tmp directory to a tarball in" + echo " directory DIR or provided with the fixed full path TGZ" + echo " when a directory is provided, the format of the" + echo " tarball's name will be {REPO_ID}-{TIMESTAMP}.tgz" + echo " [default: not set]" + echo " -v | --verbose - display more information [default: false]" + echo " -x | --http-proxy URL - provides URL for the env variable http_proxy" + echo " [default: not set]; uses env var \$http_proxy if set" + 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 " -b | --extra-bind-paths - specify extra paths to be bound into the container." + echo " To specify multiple bind paths, seperate by comma." + echo " Example: '/src:/dest:ro,/src2:/dest2:rw'" echo echo " If value for --mode is 'run', the SCRIPT/COMMAND provided is executed. If" echo " arguments to the script/command start with '-' or '--', use the flag terminator" @@ -197,6 +200,10 @@ while [[ $# -gt 0 ]]; do export https_proxy=${HTTPS_PROXY} shift 2 ;; + -b|--extra-bind-paths) + EXTRA_BIND_PATHS="$2" + shift 2 + ;; --) shift POSITIONAL_ARGS+=("$@") # save positional args @@ -439,6 +446,9 @@ fi BIND_PATHS="${EESSI_CVMFS_VAR_LIB}:/var/lib/cvmfs,${EESSI_CVMFS_VAR_RUN}:/var/run/cvmfs,${HOST_INJECTIONS}:/opt/eessi" # provide a '/tmp' inside the container BIND_PATHS="${BIND_PATHS},${EESSI_TMPDIR}:${TMP_IN_CONTAINER}" +if [[ ! -z ${EXTRA_BIND_PATHS} ]]; then + BIND_PATHS="${BIND_PATHS},${EXTRA_BIND_PATHS}" +fi [[ ${VERBOSE} -eq 1 ]] && echo "BIND_PATHS=${BIND_PATHS}" diff --git a/test_suite.sh b/test_suite.sh index 46b43ee78a..6e73fbd87c 100755 --- a/test_suite.sh +++ b/test_suite.sh @@ -157,7 +157,7 @@ if [[ "${cpuinfo}" =~ (Core\(s\) per socket:[^0-9]*([0-9]+)) ]]; then else fatal_error "Failed to get the number of cores per socket for the current test hardware with lscpu." fi -cgroup_mem_bytes=$(cat /sys/fs/cgroup/memory/slurm/uid_${UID}/job_${SLURM_JOB_ID}/memory.limit_in_bytes) +cgroup_mem_bytes=$(cat /hostsys/fs/cgroup/memory/slurm/uid_${UID}/job_${SLURM_JOB_ID}/memory.limit_in_bytes) if [[ $? -eq 0 ]]; then # Convert to MiB cgroup_mem_mib=$((cgroup_mem_bytes/(1024*1024))) From 5bfd7c1c0898ee268530295f794438cd1fd29836 Mon Sep 17 00:00:00 2001 From: Caspar van Leeuwen <33718780+casparvl@users.noreply.github.com> Date: Thu, 13 Jun 2024 16:45:32 +0200 Subject: [PATCH 2/4] Update eessi_container.sh MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Bob Dröge --- eessi_container.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/eessi_container.sh b/eessi_container.sh index eac8e74c83..55b0aa4c63 100755 --- a/eessi_container.sh +++ b/eessi_container.sh @@ -71,6 +71,9 @@ display_help() { echo "usage: $0 [OPTIONS] [[--] SCRIPT or COMMAND]" echo " OPTIONS:" echo " -a | --access {ro,rw} - ro (read-only), rw (read & write) [default: ro]" + echo " -b | --extra-bind-paths - specify extra paths to be bound into the container." + echo " To specify multiple bind paths, seperate by comma." + echo " Example: '/src:/dest:ro,/src2:/dest2:rw'" echo " -c | --container IMG - image file or URL defining the container to use" echo " [default: docker://ghcr.io/eessi/build-node:debian11]" echo " -f | --fakeroot - run the container with --fakeroot [default: false]" @@ -104,9 +107,6 @@ display_help() { echo " [default: not set]; uses env var \$http_proxy if set" 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 " -b | --extra-bind-paths - specify extra paths to be bound into the container." - echo " To specify multiple bind paths, seperate by comma." - echo " Example: '/src:/dest:ro,/src2:/dest2:rw'" echo echo " If value for --mode is 'run', the SCRIPT/COMMAND provided is executed. If" echo " arguments to the script/command start with '-' or '--', use the flag terminator" From a7fca5155a4e9c145d73c416c85e4c1e6f2c2c12 Mon Sep 17 00:00:00 2001 From: Caspar van Leeuwen Date: Thu, 13 Jun 2024 16:46:33 +0200 Subject: [PATCH 3/4] Sort alphabetically --- eessi_container.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/eessi_container.sh b/eessi_container.sh index eac8e74c83..aa5df50af6 100755 --- a/eessi_container.sh +++ b/eessi_container.sh @@ -137,6 +137,10 @@ while [[ $# -gt 0 ]]; do ACCESS="$2" shift 2 ;; + -b|--extra-bind-paths) + EXTRA_BIND_PATHS="$2" + shift 2 + ;; -c|--container) CONTAINER="$2" shift 2 @@ -200,10 +204,6 @@ while [[ $# -gt 0 ]]; do export https_proxy=${HTTPS_PROXY} shift 2 ;; - -b|--extra-bind-paths) - EXTRA_BIND_PATHS="$2" - shift 2 - ;; --) shift POSITIONAL_ARGS+=("$@") # save positional args From 13366e7c3f3c1aa59192f70e8a26e451611a15d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bob=20Dr=C3=B6ge?= Date: Thu, 13 Jun 2024 16:48:42 +0200 Subject: [PATCH 4/4] fix typo --- eessi_container.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eessi_container.sh b/eessi_container.sh index 891b793f9d..fb14e2118f 100755 --- a/eessi_container.sh +++ b/eessi_container.sh @@ -72,7 +72,7 @@ display_help() { echo " OPTIONS:" echo " -a | --access {ro,rw} - ro (read-only), rw (read & write) [default: ro]" echo " -b | --extra-bind-paths - specify extra paths to be bound into the container." - echo " To specify multiple bind paths, seperate by comma." + echo " To specify multiple bind paths, separate by comma." echo " Example: '/src:/dest:ro,/src2:/dest2:rw'" echo " -c | --container IMG - image file or URL defining the container to use" echo " [default: docker://ghcr.io/eessi/build-node:debian11]"