Skip to content

fix(docker): handle cgroup v2 'max' in memory guard (#2123) - #2196

Open
Battleplus wants to merge 1 commit into
unclecode:mainfrom
Battleplus:fix/2123-docker-memory-guard
Open

fix(docker): handle cgroup v2 'max' in memory guard (#2123)#2196
Battleplus wants to merge 1 commit into
unclecode:mainfrom
Battleplus:fix/2123-docker-memory-guard

Conversation

@Battleplus

Copy link
Copy Markdown

Summary

Fixes #2123 — On cgroup v2 with no container memory limit, memory.max contains the string "max". int("max") raised ValueError, the bare except caught it, and the function returned host memory percentage instead of container's.

Fix

Parse limit as string first, handle "max" explicitly (fall back to host total), then convert to int for numeric values.

Files changed

  • deploy/docker/utils.py (+9/-2)

On cgroup v2 with no container memory limit, memory.max contains the
string "max". int("max") raised ValueError, the bare except caught it,
and the function returned host memory percentage instead of container's.

Parse limit as string first, handle "max" explicitly, then fall back to
int conversion for numeric values.

Closes unclecode#2123
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Docker memory guard reads host RAM when no container limit is set — cgroup v2 "max" defeats get_container_memory_percent

1 participant