Shorten the cleanup grace period in the e2e tests

This commit is contained in:
2026-11-04 02:57:49 +01:00
parent 7465af5d41
commit 0fb86fed07
2 changed files with 14 additions and 1 deletions
+13 -1
View File
@@ -27,6 +27,7 @@ use crate::sandbox::Bwrap;
use crate::signals::ForwardedSignals;
const CLEANUP_GRACE_PERIOD: Duration = Duration::from_secs(5);
const CLEANUP_GRACE_PERIOD_OVERRIDE: &str = "AGENT_SANDBOX_CLEANUP_GRACE_PERIOD_MS";
pub enum SandboxMode {
Blacklist,
@@ -114,6 +115,17 @@ pub fn run(config: SandboxConfig) -> Result<ExitStatus, SandboxError> {
// bwrap ignores them: its death would SIGKILL the entrypoint through --die-with-parent.
let bwrap_process = bwrap.spawn(signal_forwarder.ignore_forwarded_signals())?;
let status = signal_forwarder.forward_until_exit(&bwrap_process)?;
process_tree::terminate_and_reap_all(CLEANUP_GRACE_PERIOD, signals::has_pending_interrupt)?;
process_tree::terminate_and_reap_all(
read_cleanup_grace_period(),
signals::has_pending_interrupt,
)?;
Ok(status)
}
fn read_cleanup_grace_period() -> Duration {
std::env::var(CLEANUP_GRACE_PERIOD_OVERRIDE)
.ok()
.and_then(|milliseconds| milliseconds.parse().ok())
.map(Duration::from_millis)
.unwrap_or(CLEANUP_GRACE_PERIOD)
}
+1
View File
@@ -134,6 +134,7 @@ fn run_with_detached_sleeper(sandbox_args: &[&str], setup: &str, marker: &str) {
);
let status = Sandbox::new(sandbox_args)
.env("AGENT_SANDBOX_CLEANUP_GRACE_PERIOD_MS", "1000")
.args(["--", "sh", "-c", &script])
.status()
.expect("agent-sandbox binary failed to execute");