Skip to content

Commit 8c3ba5d

Browse files
authored
Merge pull request #678 from casparvl/fix_memory_detection_testsuite_aws
Fix failing test step on AWS
2 parents 3ba1a39 + b82e183 commit 8c3ba5d

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

test_suite.sh

+12-3
Original file line numberDiff line numberDiff line change
@@ -168,11 +168,18 @@ if [[ "${cpuinfo}" =~ (Core\(s\) per socket:[^0-9]*([0-9]+)) ]]; then
168168
else
169169
fatal_error "Failed to get the number of cores per socket for the current test hardware with lscpu."
170170
fi
171-
cgroup_v1_mem_limit="/sys/fs/cgroup/memory/$(</proc/self/cpuset)/memory.limit_in_bytes"
172-
cgroup_v2_mem_limit="/sys/fs/cgroup/$(</proc/self/cpuset)/memory.max"
171+
172+
# The /sys inside the container is not the same as the /sys of the host
173+
# We want to extract the memory limit from the cgroup on the host (which is typically set by SLURM).
174+
# Thus, bot/test.sh bind-mounts the host's /sys/fs/cgroup into /hostsys/fs/cgroup
175+
# and that's the prefix we use to extract the memory limit from
176+
cgroup_v1_mem_limit="/hostsys/fs/cgroup/memory/$(</proc/self/cpuset)/memory.limit_in_bytes"
177+
cgroup_v2_mem_limit="/hostsys/fs/cgroup/$(</proc/self/cpuset)/memory.max"
173178
if [ -f "$cgroup_v1_mem_limit" ]; then
179+
echo "Getting memory limit from file $cgroup_v1_mem_limit"
174180
cgroup_mem_bytes=$(cat "$cgroup_v1_mem_limit")
175-
else
181+
elif [ -f "$cgroup_v2_mem_limit" ]; then
182+
echo "Getting memory limit from file $cgroup_v2_mem_limit"
176183
cgroup_mem_bytes=$(cat "$cgroup_v2_mem_limit")
177184
if [ "$cgroup_mem_bytes" = 'max' ]; then
178185
# In cgroupsv2, the memory.max file may contain 'max', meaning the group can use the full system memory
@@ -183,6 +190,8 @@ else
183190
fi
184191
cgroup_mem_bytes=$(("$cgroup_mem_kilobytes"*1024))
185192
fi
193+
else
194+
fatal_error "Both files ${cgroup_v1_mem_limit} and ${cgroup_v2_mem_limit} couldn't be found. Failed to get the memory limit from the current cgroup"
186195
fi
187196
if [[ $? -eq 0 ]]; then
188197
# Convert to MiB

0 commit comments

Comments
 (0)