diff options
author | hor911 <hor911@ydb.tech> | 2023-02-09 12:21:23 +0300 |
---|---|---|
committer | hor911 <hor911@ydb.tech> | 2023-02-09 12:21:23 +0300 |
commit | 8642d3642932f03663ba7d2d9670707c192207fd (patch) | |
tree | 80d8431bc2341a3fdea0e00aac1e4aff6a3587fa /library/cpp | |
parent | 416b62668249e5744697c7b87783c83b991996a6 (diff) | |
download | ydb-8642d3642932f03663ba7d2d9670707c192207fd.tar.gz |
Correct mem limit detection in mk8s
Diffstat (limited to 'library/cpp')
-rw-r--r-- | library/cpp/actors/core/process_stats.cpp | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/library/cpp/actors/core/process_stats.cpp b/library/cpp/actors/core/process_stats.cpp index 0fdad83da59..349d207a71e 100644 --- a/library/cpp/actors/core/process_stats.cpp +++ b/library/cpp/actors/core/process_stats.cpp @@ -9,6 +9,7 @@ #include <util/datetime/uptime.h> #include <util/system/defaults.h> #include <util/stream/file.h> +#include <util/system/fs.h> #include <util/string/vector.h> #include <util/string/split.h> @@ -101,13 +102,17 @@ namespace NActors { break; } } - if (!memoryCGroup.empty()) { - TFileInput limit("/sys/fs/cgroup/memory" + memoryCGroup + "/memory.limit_in_bytes"); - if (limit.ReadLine(line) > 0) { - CGroupMemLim = FromString<ui64>(line); - if (CGroupMemLim > (1ULL << 40)) { - CGroupMemLim = 0; - } + + TString cgroupFileName = "/sys/fs/cgroup/memory" + memoryCGroup + "/memory.limit_in_bytes"; + if (!NFs::Exists(cgroupFileName)) { + // fallback for mk8s + cgroupFileName = "/sys/fs/cgroup/memory/memory.limit_in_bytes"; + } + TFileInput limit(cgroupFileName); + if (limit.ReadLine(line) > 0) { + CGroupMemLim = FromString<ui64>(line); + if (CGroupMemLim > (1ULL << 40)) { + CGroupMemLim = 0; } } |