Skip to content

Commit

Permalink
send delete event while initial process deleted
Browse files Browse the repository at this point in the history
  • Loading branch information
mingfukuang committed Aug 2, 2024
1 parent 8fe320d commit 8fc6495
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 11 deletions.
3 changes: 2 additions & 1 deletion crates/runc-shim/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@
*/

use std::env;
use tokio::runtime::Builder;

use containerd_shim::{asynchronous::run, parse};
use tokio::runtime::Builder;

mod cgroup_memory;
mod common;
Expand Down
21 changes: 11 additions & 10 deletions crates/runc-shim/src/task.rs
Original file line number Diff line number Diff line change
Expand Up @@ -250,20 +250,21 @@ where
let exec_id_opt = req.exec_id().as_option();
let (pid, exit_status, exited_at) = container.delete(exec_id_opt).await?;
self.factory.cleanup(&self.namespace, container).await?;

let ts = convert_to_timestamp(exited_at);
// if we deleted an init task, send the task delete event
if req.exec_id().is_empty() {
containers.remove(req.id());
self.send_event(TaskDelete {
container_id: id,
pid: pid as u32,
exit_status: exit_status as u32,
exited_at: Some(ts.clone()).into(),
..Default::default()
})
.await;
}

let ts = convert_to_timestamp(exited_at);
self.send_event(TaskDelete {
container_id: id,
pid: pid as u32,
exit_status: exit_status as u32,
exited_at: Some(ts.clone()).into(),
..Default::default()
})
.await;

let mut resp = DeleteResponse::new();
resp.set_exited_at(ts);
resp.set_pid(pid as u32);
Expand Down

0 comments on commit 8fc6495

Please sign in to comment.