From 7dad501cbcc2bf901e2c0382c86f64728f8a6d1e Mon Sep 17 00:00:00 2001 From: Marcelo Carneiro do Amaral Date: Thu, 12 Oct 2023 21:55:34 +0900 Subject: [PATCH] resolve: fix resolve container id (#982) Signed-off-by: Marcelo Amaral --- pkg/cgroup/resolve_container.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/pkg/cgroup/resolve_container.go b/pkg/cgroup/resolve_container.go index 08664af83b..1f21ab4e1e 100644 --- a/pkg/cgroup/resolve_container.go +++ b/pkg/cgroup/resolve_container.go @@ -230,6 +230,11 @@ func extractPodContainerIDfromPath(path string) (string, error) { if path == unknownPath { return utils.SystemProcessName, fmt.Errorf("failed to find pod's container id") } + // as the container ID is located at the end of the path, we remove the beginning of the string to prevent bugs, as seen in issue #923 + split := strings.Split(path, "/") + size := len(split) + path = split[size-1 : size][0] + cgroup := config.GetCGroupVersion() if regexFindContainerIDPath.MatchString(path) { sub := regexFindContainerIDPath.FindAllString(path, -1)