Skip to content

Commit

Permalink
handling the cmdline change in runsc
Browse files Browse the repository at this point in the history
  • Loading branch information
def committed Mar 9, 2023
1 parent 32c6ad2 commit 0d0cdda
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion containers/registry.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
Expand Down Expand Up @@ -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"]
Expand Down

0 comments on commit 0d0cdda

Please sign in to comment.