From 75736a9d113467f79b276a88fff71d90516cceda Mon Sep 17 00:00:00 2001 From: Alex K <8418476+fearful-symmetry@users.noreply.github.com> Date: Mon, 30 Aug 2021 23:05:17 -0700 Subject: [PATCH] Fix bug with override path in cgroups (#27620) * fix bug with override path * add changelog (cherry picked from commit f073c4567ceb2d92a996d8202f9c2d1a1008c4d4) --- CHANGELOG.next.asciidoc | 4 ++++ libbeat/metric/system/cgroup/reader.go | 4 ++-- .../processors/add_process_metadata/gosigar_cid_provider.go | 2 ++ 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.next.asciidoc b/CHANGELOG.next.asciidoc index eebb99465c2..16a5d4b8993 100644 --- a/CHANGELOG.next.asciidoc +++ b/CHANGELOG.next.asciidoc @@ -130,6 +130,10 @@ https://github.com/elastic/beats/compare/v7.0.0-alpha2...master[Check the HEAD d - Improve `perfmon` metricset performance. {pull}26886[26886] - Preserve annotations in a kubernetes namespace metadata {pull}27045[27045] - Allow conditional processing in `decode_xml` and `decode_xml_wineventlog`. {pull}27159[27159] +- Fix build constraint that caused issues with doc builds. {pull}27381[27381] +- Do not try to load ILM policy if `check_exists` is `false`. {pull}27508[27508] {issue}26322[26322] +- Fix bug with cgroups hierarchy override path in cgroups {pull}27620[27620] +- Beat `setup kibana` command may use the elasticsearch API key defined in `output.elasticsearch.api_key`. {issue}24015[24015] {pull}27540[27540] *Auditbeat* diff --git a/libbeat/metric/system/cgroup/reader.go b/libbeat/metric/system/cgroup/reader.go index cb08ef028c6..7b1c7277382 100644 --- a/libbeat/metric/system/cgroup/reader.go +++ b/libbeat/metric/system/cgroup/reader.go @@ -189,7 +189,7 @@ func (r *Reader) GetV1StatsForProcess(pid int) (*StatsV1, error) { stats.Path, stats.ID = getCommonCgroupMetadata(paths) stats.Version = CgroupsV1 for conName, cgPath := range paths { - if r.ignoreRootCgroups && cgPath.ControllerPath == "/" { + if r.ignoreRootCgroups && (cgPath.ControllerPath == "/" && r.cgroupsHierarchyOverride != cgPath.ControllerPath) { continue } err := getStatsV1(cgPath, conName, &stats) @@ -212,7 +212,7 @@ func (r *Reader) GetV2StatsForProcess(pid int) (*StatsV2, error) { stats.Path, stats.ID = getCommonCgroupMetadata(paths) stats.Version = CgroupsV2 for conName, cgPath := range paths { - if r.ignoreRootCgroups && cgPath.ControllerPath == "/" { + if r.ignoreRootCgroups && (cgPath.ControllerPath == "/" && r.cgroupsHierarchyOverride != cgPath.ControllerPath) { continue } err := getStatsV2(cgPath, conName, &stats) diff --git a/libbeat/processors/add_process_metadata/gosigar_cid_provider.go b/libbeat/processors/add_process_metadata/gosigar_cid_provider.go index 9c124e188bd..2a1d934117c 100644 --- a/libbeat/processors/add_process_metadata/gosigar_cid_provider.go +++ b/libbeat/processors/add_process_metadata/gosigar_cid_provider.go @@ -109,6 +109,8 @@ func (p gosigarCidProvider) getProcessCgroups(pid int) (map[string]cgroup.Contro // ID is found then an empty string is returned. // Example: // /kubepods/besteffort/pod9b9e44c2-00fd-11ea-95e9-080027421ddf/2bb9fd4de339e5d4f094e78bb87636004acfe53f5668104addc761fe4a93588e +// V2 Example: +// /kubepods.slice/kubepods-burstable.slice/kubepods-burstable-pod1f306eaea646903787fd7cc4eb6be515.slice/crio-eac98011dea91157038ca797f2141754106e074b7242721c7170a642a2204a54.scope func (p gosigarCidProvider) getCid(cgroups map[string]cgroup.ControllerPath) string { // if regex defined use it to find cid if len(p.cgroupRegex) != 0 {