From b0786f00321750479b9c2b816c5f1f3196905bd0 Mon Sep 17 00:00:00 2001 From: Roberto Scolaro Date: Thu, 16 Jan 2025 11:54:49 +0000 Subject: [PATCH] chore(libsinsp/runc): report correct container id with short cid Signed-off-by: Roberto Scolaro --- userspace/libsinsp/runc.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/userspace/libsinsp/runc.cpp b/userspace/libsinsp/runc.cpp index 2fcad374b8..07239146d2 100644 --- a/userspace/libsinsp/runc.cpp +++ b/userspace/libsinsp/runc.cpp @@ -72,11 +72,12 @@ bool match_one_container_id(const std::string &cgroup, return false; } + // Avoid system host cgroups. if(cgroup.rfind("/default/") == 0 && !endswith(cgroup, ".service") && !endswith(cgroup, ".slice")) { size_t reported_len = end_pos - start_pos >= REPORTED_CONTAINER_ID_LENGTH ? REPORTED_CONTAINER_ID_LENGTH - : end_pos; + : end_pos - start_pos; container_id = cgroup.substr(start_pos, reported_len); return true; }