Skip to content
Open
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 deploy/docker/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -420,9 +420,16 @@ def get_container_memory_percent() -> float:
limit_path = Path("/sys/fs/cgroup/memory/memory.limit_in_bytes")

usage = int(usage_path.read_text())
limit = int(limit_path.read_text())
limit_str = limit_path.read_text().strip()

# Handle unlimited (v2: "max", v1: > 1e18)
# Handle unlimited: cgroup v2 writes "max", cgroup v1 writes > 1e18
if limit_str == "max" or not limit_str:
import psutil
limit = psutil.virtual_memory().total
else:
limit = int(limit_str)

# Handle cgroup v1 unlimited (limit > 1e18)
if limit > 1e18:
import psutil
limit = psutil.virtual_memory().total
Expand Down