pub struct SandboxPool { /* private fields */ }Expand description
Sandbox pool for warm sandbox management
Maintains:
- Warm pool: Pre-created sandboxes ready for immediate use
- Active sandboxes: Sandboxes currently in use by workloads
§Admission control (#525 P2)
acquire is gated by an [AdmissionTracker]: fail-closed identity,
per-Subject/per-group quotas, a bounded wait-queue, and resource
(cpu/memory/GPU) fit — see runtime::admission for the full design and
its sign-off-flagged judgment calls.
§Backend placement (#525 P2, scope item 4)
A SandboxPool is bound to exactly one pre-resolved
SandboxBackend, selected once at construction via
super::resolve_backend (the fail-closed inventory-registry seam,
#507/#516) — never re-selected per request. Routing individual
acquire() calls to different backends (e.g. GPU workloads to kata,
CPU-only ones to nspawn, within the same pool) is not implemented:
it would require restructuring SandboxPool into a router over multiple
backend-specific pools, a larger architectural change than this ticket’s
scope. Flagged as a follow-up, not a silent gap — acquire never
bypasses the fail-closed backend-resolution seam; it just doesn’t have
more than one backend to choose among.
Implementations§
Source§impl SandboxPool
impl SandboxPool
Sourcepub fn new(config: PoolConfig, backend: Arc<dyn SandboxBackend>) -> Self
pub fn new(config: PoolConfig, backend: Arc<dyn SandboxBackend>) -> Self
Create a new sandbox pool with a backend.
Uses the fail-closed admission::DenyUnknownGroupValidator — the
production default until a membership-backed validator is wired: any
non-empty hyprstream.io/group selector is rejected at admission
(B′); the no-selector case is unaffected.
Sourcepub fn with_group_validator(
config: PoolConfig,
backend: Arc<dyn SandboxBackend>,
group_validator: Arc<dyn GroupSelectorValidator>,
) -> Self
pub fn with_group_validator( config: PoolConfig, backend: Arc<dyn SandboxBackend>, group_validator: Arc<dyn GroupSelectorValidator>, ) -> Self
Create a pool with an explicit admission::GroupSelectorValidator
(e.g. one backed by a real membership source such as
PlacementIndex::is_member, or a test double). Mirrors
[AdmissionTracker::with_group_validator].
Sourcepub fn backend(&self) -> &dyn SandboxBackend
pub fn backend(&self) -> &dyn SandboxBackend
Get a reference to the backend
Sourcepub async fn initialize(&self) -> Result<()>
pub async fn initialize(&self) -> Result<()>
Initialize the warm pool with pre-created sandboxes
Sourcepub async fn acquire(
self: &Arc<Self>,
subject: &Subject,
config: &PodSandboxConfig,
) -> Result<String>
pub async fn acquire( self: &Arc<Self>, subject: &Subject, config: &PodSandboxConfig, ) -> Result<String>
Acquire a sandbox from the pool
Prefers warm sandboxes, creates new if none available.
§Admission control (#525 P2)
subject must be a verified, non-anonymous Subject — an
unauthenticated caller is rejected fail-closed before any capacity or
quota bookkeeping happens. Admission (capacity + per-Subject/per-group
quota + cpu/memory/GPU fit) is reserved atomically under one lock
(see runtime::admission) before this method ever touches the warm
pool or the backend — never check-then-place.
A request that only capacity (not quota) blocks may wait, bounded by
PoolConfig::admission’s queue settings; see WorkerError::QueueFull
/ WorkerError::QueueTimeout / WorkerError::AdmissionDenied for
the distinct failure modes.
Sourcepub async fn release(self: &Arc<Self>, sandbox_id: &str) -> Result<()>
pub async fn release(self: &Arc<Self>, sandbox_id: &str) -> Result<()>
Release a sandbox back to the pool or destroy it
Sourcepub async fn get(&self, sandbox_id: &str) -> Option<PodSandbox>
pub async fn get(&self, sandbox_id: &str) -> Option<PodSandbox>
Get a sandbox by ID
Sourcepub async fn list_active(&self) -> Vec<PodSandbox>
pub async fn list_active(&self) -> Vec<PodSandbox>
List all active sandboxes
Auto Trait Implementations§
impl !Freeze for SandboxPool
impl !RefUnwindSafe for SandboxPool
impl Send for SandboxPool
impl Sync for SandboxPool
impl Unpin for SandboxPool
impl UnsafeUnpin for SandboxPool
impl !UnwindSafe for SandboxPool
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more