MCPcopy Create free account
hub / github.com/NVIDIA/OpenShell / validate_sandbox_create

Method validate_sandbox_create

crates/openshell-driver-kubernetes/src/driver.rs:419–437  ·  view source on GitHub ↗
(&self, sandbox: &Sandbox)

Source from the content-addressed store, hash-verified

417 }
418
419 pub async fn validate_sandbox_create(&self, sandbox: &Sandbox) -> Result<(), tonic::Status> {
420 let _ = KubernetesSandboxDriverConfig::from_sandbox(sandbox)
421 .map_err(tonic::Status::invalid_argument)?;
422 let gpu_requirements = sandbox
423 .spec
424 .as_ref()
425 .and_then(|spec| driver_gpu_requirements(spec.resource_requirements.as_ref()));
426 validate_gpu_request(gpu_requirements)?;
427 if gpu_requirements.is_some()
428 && !self.has_gpu_capacity().await.map_err(|err| {
429 tonic::Status::internal(format!("check GPU node capacity failed: {err}"))
430 })?
431 {
432 return Err(tonic::Status::failed_precondition(
433 "GPU sandbox requested, but the active gateway has no allocatable GPUs. Please refer to documentation and use `openshell doctor` commands to inspect GPU support and gateway configuration.",
434 ));
435 }
436 Ok(())
437 }
438
439 pub async fn get_sandbox(&self, name: &str) -> Result<Option<Sandbox>, String> {
440 info!(

Callers

nothing calls this directly

Calls 3

driver_gpu_requirementsFunction · 0.85
has_gpu_capacityMethod · 0.80
validate_gpu_requestFunction · 0.70

Tested by

no test coverage detected