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:
Alex Lyn
2026-04-30 16:32:24 +08:00
parent 610f538c8e
commit 7eae9d0fd6
3 changed files with 7 additions and 2 deletions

View File

@@ -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)]

View File

@@ -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,
}))
}

View File

@@ -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,
})
}