Skip to content

Commit

Permalink
chore(libsinsp/runc): report correct container id with short cid
Browse files Browse the repository at this point in the history
Signed-off-by: Roberto Scolaro <[email protected]>
  • Loading branch information
therealbobo authored and poiana committed Jan 16, 2025
1 parent 8e1b1a3 commit b0786f0
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion userspace/libsinsp/runc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit b0786f0

Please sign in to comment.