Skip to content

Commit

Permalink
When the systemd cgroup driver is used, cgroup paths will have hyphen…
Browse files Browse the repository at this point in the history
…s (e.g. in pod UIDs)

escaped to underscores. When we're parsing cgroups, we must therefore unescape them.

refs elastic/apm#165
  • Loading branch information
beniwohli committed Nov 12, 2019
1 parent 09c3129 commit 330c0b8
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion elasticapm/utils/cgroup.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,6 @@ def parse_cgroups(filehandle):
pod_id = kubepods_match.group(1)
if not pod_id:
pod_id = kubepods_match.group(2)
return {"container": {"id": container_id}, "kubernetes": {"pod": {"uid": pod_id}}}
return {"container": {"id": container_id}, "kubernetes": {"pod": {"uid": pod_id.replace("_", "-")}}}
elif container_id_regexp.match(container_id):
return {"container": {"id": container_id}}
2 changes: 1 addition & 1 deletion tests/utils/cgroup_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
"1:name=systemd:/kubepods.slice/kubepods-burstable.slice/kubepods-burstable-pod90d81341_92de_11e7_8cf2_507b9d4141fa.slice/crio-2227daf62df6694645fee5df53c1f91271546a9560e8600a525690ae252b7f63.scope",
{
"container": {"id": "2227daf62df6694645fee5df53c1f91271546a9560e8600a525690ae252b7f63"},
"kubernetes": {"pod": {"uid": "90d81341_92de_11e7_8cf2_507b9d4141fa"}},
"kubernetes": {"pod": {"uid": "90d81341-92de-11e7-8cf2-507b9d4141fa"}},
},
),
(
Expand Down

0 comments on commit 330c0b8

Please sign in to comment.