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 <roman@dragonflydb.io>
This commit is contained in:
Roman Gershman 2023-12-30 13:31:40 +02:00 committed by GitHub
parent c7093c40e5
commit ddbdf63470
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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