Skip to content

Commit

Permalink
fix: enable kubernetes labels for k8s with containerd
Browse files Browse the repository at this point in the history
PR corresponding to the changes: hubblo-org#327
  • Loading branch information
bele committed Oct 24, 2023
1 parent 5525c68 commit ec337ac
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
6 changes: 3 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM rust:1.59 as planner
FROM rust:1.70 as planner
WORKDIR app

RUN cargo install cargo-chef
Expand All @@ -7,15 +7,15 @@ COPY . .
# Analyze dependencies
RUN cargo chef prepare --recipe-path recipe.json

FROM rust:1.59 as cacher
FROM rust:1.70 as cacher
WORKDIR app
RUN cargo install cargo-chef
COPY --from=planner /app/recipe.json recipe.json

# Cache dependencies
RUN cargo chef cook --release --recipe-path recipe.json

FROM rust:1.59 as builder
FROM rust:1.70 as builder
WORKDIR app
COPY . .

Expand Down
8 changes: 7 additions & 1 deletion src/sensors/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -419,7 +419,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 @@ -587,6 +587,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();
}
Ok(container_id)
}

Expand Down

0 comments on commit ec337ac

Please sign in to comment.