From ddbdf6347073294785bd82d39d4b0d568e689e7e Mon Sep 17 00:00:00 2001 From: Roman Gershman Date: Sat, 30 Dec 2023 13:31:40 +0200 Subject: [PATCH] fix: relax the requirement for parsing successfully container limits (#2352) We parse the container limits for heuristics that deduces memory/cpu capacities automatically. It's ok if we fail on some less common systems since there are manual overrides that allows specifying these limits explicitly. Signed-off-by: Roman Gershman --- src/server/dfly_main.cc | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/server/dfly_main.cc b/src/server/dfly_main.cc index 540038f4f..e89a99fd0 100644 --- a/src/server/dfly_main.cc +++ b/src/server/dfly_main.cc @@ -405,7 +405,8 @@ void GetCGroupPath(string* memory_path, string* cpu_path) { } } -void UpdateResourceLimitsIfInsideContainer(io::MemInfoData* mdata, size_t* max_threads) { +// returns true on success. +bool UpdateResourceLimitsIfInsideContainer(io::MemInfoData* mdata, size_t* max_threads) { using absl::StrCat; // did we succeed in reading *something*? if not, exit. @@ -433,8 +434,7 @@ void UpdateResourceLimitsIfInsideContainer(io::MemInfoData* mdata, size_t* max_t GetCGroupPath(&mem_path, &cpu_path); if (mem_path.empty() || cpu_path.empty()) { - VLOG(1) << "Failed to get cgroup path, error"; - return; + return true; // not a container } VLOG(1) << "mem_path = " << mem_path; @@ -519,9 +519,10 @@ void UpdateResourceLimitsIfInsideContainer(io::MemInfoData* mdata, size_t* max_t if (!read_something) { LOG(ERROR) << "Failed in deducing any cgroup limits with paths " << mem_path << " and " - << cpu_path << ". Exiting."; - exit(1); + << cpu_path; + return false; } + return true; } #endif