Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Kubernetes integration when using cgroups v2 #327

Open
wants to merge 2 commits into
base: dev
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion src/sensors/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ impl ProcessTracker {
#[cfg(feature = "containers")]
let regex_cgroup_docker = Regex::new(r"^.*/docker.*$").unwrap();
#[cfg(feature = "containers")]
let regex_cgroup_kubernetes = Regex::new(r"^/kubepods.*$").unwrap();
let regex_cgroup_kubernetes = Regex::new(r"/kubepods.*$").unwrap();
#[cfg(feature = "containers")]
let regex_cgroup_containerd = Regex::new("/system.slice/containerd.service/.*$").unwrap();

Expand Down Expand Up @@ -429,6 +429,12 @@ impl ProcessTracker {
if container_id.contains("cri-containerd") {
container_id = container_id.split(':').last().unwrap().to_string();
}
if container_id.starts_with("cri-containerd-") {
container_id = container_id
.strip_prefix("cri-containerd-")
.unwrap()
.to_string();
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I needed to add this to be able to extract the container ID successfully.

Ok(container_id)
}

Expand Down