From 0d0cdda8539870db9a73763ed4db0c52612e5343 Mon Sep 17 00:00:00 2001 From: Nikolay Sivko Date: Thu, 9 Mar 2023 17:36:17 +0300 Subject: [PATCH] handling the cmdline change in `runsc` --- containers/registry.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/containers/registry.go b/containers/registry.go index 94743ef..f76474f 100644 --- a/containers/registry.go +++ b/containers/registry.go @@ -246,8 +246,9 @@ func (r *Registry) getOrCreateContainer(pid uint32) *Container { cmdline := proc.GetCmdline(pid) parts := bytes.Split(cmdline, []byte{0}) if len(parts) > 0 { + cmd := parts[0] lastArg := parts[len(parts)-1] - if bytes.HasSuffix(parts[0], []byte("runsc-sandbox")) && containerIdRegexp.Match(lastArg) { + if (bytes.HasSuffix(cmd, []byte("runsc-sandbox")) || bytes.HasSuffix(cmd, []byte("runsc"))) && containerIdRegexp.Match(lastArg) { cg.ContainerId = string(lastArg) } } @@ -309,6 +310,9 @@ func calcId(cg *cgroup.Cgroup, md *ContainerMetadata) ContainerID { default: return "" } + if cg.ContainerId == "" { + return "" + } if md.labels["io.kubernetes.pod.name"] != "" { pod := md.labels["io.kubernetes.pod.name"] namespace := md.labels["io.kubernetes.pod.namespace"]