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

Make memory tuning cgroups v2 compatible #262

Merged
merged 1 commit into from
Jul 1, 2024
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
11 changes: 9 additions & 2 deletions docker-entrypoint-initdb.d/001_timescaledb_tune.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,16 @@ fi

if [ -z "${TS_TUNE_MEMORY:-}" ]; then
# See if we can get the container's total allocated memory from the cgroups metadata
if [ -f /sys/fs/cgroup/memory/memory.limit_in_bytes ]; then
# Try with cgroups v2 first.
if [ -f /sys/fs/cgroup/cgroup.controllers ]; then
TS_TUNE_MEMORY=$(cat /sys/fs/cgroup/memory.max)
TS_CGROUPS_MAX_MEM=true
# cgroups v2 is not available, try with cgroups v1
elif [ -f /sys/fs/cgroup/memory/memory.limit_in_bytes ]; then
TS_TUNE_MEMORY=$(cat /sys/fs/cgroup/memory/memory.limit_in_bytes)

TS_CGROUPS_MAX_MEM=true
fi
if [ "${TS_CGROUPS_MAX_MEM:-false}" != "false" ]; then
if [ "${TS_TUNE_MEMORY}" = "18446744073709551615" ]; then
# Bash seems to error out for numbers greater than signed 64-bit,
# so if the value of limit_in_bytes is the 64-bit UNSIGNED max value
Expand Down
Loading