diff options
Diffstat (limited to 'src/sandbox/kata.rs')
| -rw-r--r-- | src/sandbox/kata.rs | 30 |
1 files changed, 18 insertions, 12 deletions
diff --git a/src/sandbox/kata.rs b/src/sandbox/kata.rs index 26e9acc..27005bd 100644 --- a/src/sandbox/kata.rs +++ b/src/sandbox/kata.rs @@ -1,7 +1,9 @@ use std::collections::HashMap; use std::io::BufReader; use std::net::{TcpListener, TcpStream}; +#[cfg(feature = "test-support")] use std::path::PathBuf; +#[cfg(feature = "test-support")] use std::process::{Child, Command}; use std::sync::atomic::{AtomicU64, Ordering}; use std::sync::{Arc, Mutex, OnceLock}; @@ -121,17 +123,27 @@ impl Provisioner for K8sSandboxProvisioner { } } +/// Provisions sandboxes by running the local `sandbox-agent` binary. +/// +/// Test-tier only. Production selects `K8sSandboxProvisioner` when the config +/// names an agent-sandbox backend (kata.rs:193); nothing in the crate ever +/// constructs this type. It exists so tests can drive the real agent protocol +/// against the shim binary without a cluster, which is a more valuable test +/// than the absence of one — so it is gated rather than deleted. +#[cfg(feature = "test-support")] pub struct LocalAgentProvisioner { pub bin: PathBuf, children: Mutex<HashMap<String, Child>>, } +#[cfg(feature = "test-support")] impl LocalAgentProvisioner { pub fn new(bin: impl Into<PathBuf>) -> Self { Self { bin: bin.into(), children: Mutex::new(HashMap::new()) } } } +#[cfg(feature = "test-support")] impl Provisioner for LocalAgentProvisioner { fn provision(&self, req: &ProvisionRequest) -> Result<()> { let child = Command::new(&self.bin) @@ -238,18 +250,12 @@ impl KataBackend { }) } - /// NOTE: `KataBackend::reclaim` used to sit here and called nothing but - /// `self.provisioner.reclaim`, which the pool already calls itself at the - /// reaping site. Nothing — not a test — ever called the wrapper, so it is - /// gone rather than gated. The census had credited it to `tests/kata.rs`, - /// where the TTL test implements the *trait's* `reclaim` on a null - /// provisioner: same word, different function. - /// Test-tier in practice — `tests/remote_agent.rs` drives a real agent - /// through it — but it is a plain accessor on a public type, so it is - /// left public rather than gated behind a feature. - pub fn local_addr(&self) -> &str { - &self.addr - } + // NOTE: `KataBackend::reclaim` used to sit here and called nothing but + // `self.provisioner.reclaim`, which the pool already calls itself at the + // reaping site. Nothing — not a test — ever called the wrapper, so it is + // gone rather than gated. The census had credited it to `tests/kata.rs`, + // where the TTL test implements the *trait's* `reclaim` on a null + // provisioner: same word, different function. fn nonce(&self) -> String { let n = self.counter.fetch_add(1, Ordering::SeqCst); |
