Skip to content

Commit

Permalink
Merge pull request #672 from axw/k8s-systemd-unescape-pod-uid
Browse files Browse the repository at this point in the history
internal/hostutil: unescape systemd cgroup paths
  • Loading branch information
axw authored Nov 12, 2019
2 parents 9720dc3 + 8b54c39 commit 0365ba9
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 3 additions & 1 deletion internal/apmhostutil/container_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,9 @@ func readCgroupContainerInfo(r io.Reader) (*model.Container, *model.Kubernetes,
hostname, _ := os.Hostname()
uid := match[1]
if uid == "" {
uid = match[2]
// Systemd cgroup driver is being used,
// so we need to unescape '_' back to '-'.
uid = strings.Replace(match[2], "_", "-", -1)
}
kubernetes = &model.Kubernetes{
Pod: &model.KubernetesPod{
Expand Down
2 changes: 1 addition & 1 deletion internal/apmhostutil/container_linux_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ func TestCgroupContainerInfoKubernetesSystemd(t *testing.T) {
assert.Equal(t, &model.Container{ID: "2227daf62df6694645fee5df53c1f91271546a9560e8600a525690ae252b7f63"}, container)
assert.Equal(t, &model.Kubernetes{
Pod: &model.KubernetesPod{
UID: "90d81341_92de_11e7_8cf2_507b9d4141fa",
UID: "90d81341-92de-11e7-8cf2-507b9d4141fa",
Name: hostname,
},
}, kubernetes)
Expand Down

0 comments on commit 0365ba9

Please sign in to comment.