mirror of
https://github.com/dragonflydb/dragonfly.git
synced 2025-05-10 18:05:44 +02:00
fix: ignore unexpected contents for /sys/fs/cgroup/cpu.max (#2394)
Fixes #2391 Signed-off-by: Roman Gershman <roman@dragonflydb.io>
This commit is contained in:
parent
b8af49cfe5
commit
e9453e62e4
1 changed files with 14 additions and 13 deletions
|
@ -475,22 +475,23 @@ bool UpdateResourceLimitsIfInsideContainer(io::MemInfoData* mdata, size_t* max_t
|
||||||
if (auto cpu = ReadFileToString(StrCat(path, "/cpu.max")); cpu.has_value()) {
|
if (auto cpu = ReadFileToString(StrCat(path, "/cpu.max")); cpu.has_value()) {
|
||||||
vector<string_view> res = absl::StrSplit(*cpu, ' ');
|
vector<string_view> res = absl::StrSplit(*cpu, ' ');
|
||||||
|
|
||||||
CHECK_EQ(res.size(), 2u);
|
// Some linux distributions do not have anything there.
|
||||||
|
if (res.size() == 2u) {
|
||||||
|
if (res[0] == "max")
|
||||||
|
*output = 0u;
|
||||||
|
else {
|
||||||
|
CHECK(absl::SimpleAtod(res[0], &count))
|
||||||
|
<< "Failed in parsing cgroupv2 cpu count, path = " << path << " (read: " << *cpu
|
||||||
|
<< ")";
|
||||||
|
CHECK(absl::SimpleAtod(res[1], ×hare))
|
||||||
|
<< "Failed in parsing cgroupv2 cpu timeshare, path = " << path << " (read: " << *cpu
|
||||||
|
<< ")";
|
||||||
|
|
||||||
if (res[0] == "max")
|
*output = static_cast<size_t>(ceil(count / timeshare));
|
||||||
*output = 0u;
|
}
|
||||||
else {
|
|
||||||
CHECK(absl::SimpleAtod(res[0], &count))
|
|
||||||
<< "Failed in parsing cgroupv2 cpu count, path = " << path << " (read: " << *cpu << ")";
|
|
||||||
CHECK(absl::SimpleAtod(res[1], ×hare))
|
|
||||||
<< "Failed in parsing cgroupv2 cpu timeshare, path = " << path << " (read: " << *cpu
|
|
||||||
<< ")";
|
|
||||||
|
|
||||||
*output = static_cast<size_t>(ceil(count / timeshare));
|
read_something = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
read_something = true;
|
|
||||||
|
|
||||||
} else if (auto quota = ReadFileToString(StrCat(path, "/cpu.cfs_quota_us"));
|
} else if (auto quota = ReadFileToString(StrCat(path, "/cpu.cfs_quota_us"));
|
||||||
quota.has_value()) {
|
quota.has_value()) {
|
||||||
auto period = ReadFileToString(StrCat(path, "/cpu.cfs_period_us"));
|
auto period = ReadFileToString(StrCat(path, "/cpu.cfs_period_us"));
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue