Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Free memory report now accurate in nested cgroups
This commit causes 'determineMemoryLimit' to read the maximum available memory from the 'heirarchical_memory_limit' field in the cgroup's 'memory.stat' file, rather than reading it from the 'memory.limit_in_bytes' file. Without this change, gosigar will report the memory constraints of the outermost non-root cgroup that contains the one we're running in, rather than the constraints of the cgroup that contains us. People have reported that both Docker and Kubernetes constrain containers in this way, so this change makes gosigar correct in those conditions. Kenneth Lakin reports that he is now unsure why we would ever consult the 'memory.limit_in_bytes' file, as 'heirarchical_memory_limit' seems to always give us the information we want, but that he is too cautious to suggest that we stop consulting 'memory.limit_in_bytes' entirely. (This commit message was written by Kenneth Lakin. Blame him for any inaccuracies, typos, or purple prose.) Authored-by: Nicholaswang <wzhever@gmail.com>
- Loading branch information