Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Fix not reading limits when cgroup v2 used #107

Merged
merged 1 commit into from
Sep 29, 2023
Merged
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
14 changes: 9 additions & 5 deletions src/main/scripts/start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -309,11 +309,15 @@ fi
echo $$ > ${ANCHOR_FILE}

if [ "$MEM_LIMIT_MB" = "" ]; then
DOCKER_LIM_FILE="/sys/fs/cgroup/memory/memory.limit_in_bytes"

if [ -e "${DOCKER_LIM_FILE}" ]; then
MEM_LIMIT_MB=$(($(cat ${DOCKER_LIM_FILE})/1024/1024))
echo "Using process mem limit of ${MEM_LIMIT_MB}MiB from ${DOCKER_LIM_FILE}"
CGROUP_V1_LIM_FILE="/sys/fs/cgroup/memory/memory.limit_in_bytes"
CGROUP_V2_LIM_FILE="/sys/fs/cgroup/memory.max"

if [ -e "${CGROUP_V1_LIM_FILE}" ]; then
MEM_LIMIT_MB=$(($(cat ${CGROUP_V1_LIM_FILE})/1024/1024))
echo "Using process mem limit of ${MEM_LIMIT_MB}MiB from ${CGROUP_V1_LIM_FILE}"
elif [ -e "${CGROUP_V2_LIM_FILE}" ]; then
MEM_LIMIT_MB=$(($(cat ${CGROUP_V2_LIM_FILE})/1024/1024))
echo "Using process mem limit of ${MEM_LIMIT_MB}MiB from ${CGROUP_V2_LIM_FILE}"
else
MEM_LIMIT_MB="1536"
echo "No process mem limit provided or found, defaulting to ${MEM_LIMIT_MB}MiB"
Expand Down