diff --git a/crates/runc-shim/src/main.rs b/crates/runc-shim/src/main.rs index 2998f2f8..492d3422 100644 --- a/crates/runc-shim/src/main.rs +++ b/crates/runc-shim/src/main.rs @@ -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; diff --git a/crates/runc-shim/src/task.rs b/crates/runc-shim/src/task.rs index eec1237d..b9041a7a 100644 --- a/crates/runc-shim/src/task.rs +++ b/crates/runc-shim/src/task.rs @@ -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);