Skip to content

Commit

Permalink
Adjust osprobe assertion for burst cpu (#86990) (#86997)
Browse files Browse the repository at this point in the history
When gathering v1 cgroup cpu stats, the file is expected to have 3
lines. However, if the burst feature of cpu accounting is enabled, it
will actually have 5 lines. This commit adjusts the assertion to allow
for the extra lines. We ignore these lines already in the parsing of the
calling method. Unfortunately this is not currently easy to test, and no
tests exist. Give it is just an assertion that is relaxing, I think it's
ok to fix this issue, and separately work on revamping the OsProbe
tests.
  • Loading branch information
rjernst committed May 23, 2022
1 parent 8ea46e3 commit ccb107e
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
5 changes: 5 additions & 0 deletions docs/changelog/86990.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
pr: 86990
summary: Adjust osprobe assertion for burst cpu
area: Infra/Core
type: bug
issues: []
Original file line number Diff line number Diff line change
Expand Up @@ -463,14 +463,21 @@ private OsStats.Cgroup.CpuStat getCgroupCpuAcctCpuStat(final String controlGroup
* nr_throttled} is the number of times tasks in the given control group have been throttled, and {@code throttled_time} is the total
* time in nanoseconds for which tasks in the given control group have been throttled.
*
* If the burst feature of the scheduler is enabled, the statistics contain an additional two fields of the form
* <blockquote><pre>
* nr_bursts \d+
* burst_time
* </pre></blockquote>
* These additional fields are currently ignored.
*
* @param controlGroup the control group to which the Elasticsearch process belongs for the {@code cpu} subsystem
* @return the lines from {@code cpu.stat}
* @throws IOException if an I/O exception occurs reading {@code cpu.stat} for the control group
*/
@SuppressForbidden(reason = "access /sys/fs/cgroup/cpu")
List<String> readSysFsCgroupCpuAcctCpuStat(final String controlGroup) throws IOException {
final List<String> lines = Files.readAllLines(PathUtils.get("/sys/fs/cgroup/cpu", controlGroup, "cpu.stat"));
assert lines != null && lines.size() == 3;
assert lines != null && (lines.size() == 3 || lines.size() == 5);
return lines;
}

Expand Down

0 comments on commit ccb107e

Please sign in to comment.