mirror of
https://github.com/kata-containers/kata-containers.git
synced 2026-05-18 05:36:24 +00:00
runtime-rs: Update sandbox status to include created_at field
Ensure the `created_at` timestamp is correctly propagated in the sandbox status. Although `created_at` is present in the `SandboxStatus` and `SandboxStatusResponse` data structures, it was previously omitted during the status transition. This commit completes the implementation by passing the value recorded during sandbox initialization. Signed-off-by: Alex Lyn <alex.lyn@antgroup.com>
This commit is contained in:
@@ -233,6 +233,7 @@ pub struct SandboxStatus {
|
||||
pub pid: u32,
|
||||
pub state: String,
|
||||
pub info: std::collections::HashMap<String, String>,
|
||||
pub created_at: Option<std::time::SystemTime>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
|
||||
@@ -581,7 +581,7 @@ impl RuntimeHandlerManager {
|
||||
sandbox_id: status.sandbox_id,
|
||||
pid: status.pid,
|
||||
state: status.state,
|
||||
created_at: None,
|
||||
created_at: status.created_at,
|
||||
exited_at: None,
|
||||
}))
|
||||
}
|
||||
|
||||
@@ -98,6 +98,7 @@ pub enum SandboxState {
|
||||
struct SandboxInner {
|
||||
state: SandboxState,
|
||||
exit_info: Option<SandboxExitInfo>,
|
||||
created_at: Option<SystemTime>,
|
||||
}
|
||||
|
||||
impl SandboxInner {
|
||||
@@ -105,6 +106,7 @@ impl SandboxInner {
|
||||
Self {
|
||||
state: SandboxState::Init,
|
||||
exit_info: None,
|
||||
created_at: None,
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -864,6 +866,7 @@ impl Sandbox for VirtSandbox {
|
||||
.context("create sandbox")?;
|
||||
|
||||
inner.state = SandboxState::Running;
|
||||
inner.created_at = Some(std::time::SystemTime::now());
|
||||
|
||||
let sandbox = self.clone();
|
||||
tokio::spawn(async move {
|
||||
@@ -985,7 +988,8 @@ impl Sandbox for VirtSandbox {
|
||||
sandbox_id: self.sid.clone(),
|
||||
pid: std::process::id(),
|
||||
state,
|
||||
..Default::default()
|
||||
info: std::collections::HashMap::new(),
|
||||
created_at: inner.created_at,
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user