diff --git a/tap/tlstapper/tls_process_discoverer.go b/tap/tlstapper/tls_process_discoverer.go index df785d2b6..b3c217385 100644 --- a/tap/tlstapper/tls_process_discoverer.go +++ b/tap/tlstapper/tls_process_discoverer.go @@ -132,8 +132,22 @@ func extractCgroup(lines []string) string { return "" } +// cgroup in the /proc//cgroup may look something like +// +// /system.slice/docker-.scope +// /system.slice/containerd-.scope +// /kubepods.slice/kubepods-burstable.slice/kubepods-burstable-pod3beae8e0_164d_4689_a087_efd902d8c2ab.slice/docker-.scope +// /kubepods/besteffort/pod7709c1d5-447c-428f-bed9-8ddec35c93f4/ +// +// This function extract the out of the cgroup path, the should match +// the "Container ID:" field when running kubectl describe pod +// func normalizeCgroup(cgrouppath string) string { basename := strings.TrimSpace(path.Base(cgrouppath)) + + if strings.Contains(basename, "-") { + basename = basename[strings.Index(basename, "-") + 1:] + } if strings.Contains(basename, ".") { return strings.TrimSuffix(basename, filepath.Ext(basename))