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

Method list_sandboxes

crates/openshell-driver-kubernetes/src/driver.rs:477–525  ·  view source on GitHub ↗
(&self)

Source from the content-addressed store, hash-verified

475 }
476
477 pub async fn list_sandboxes(&self) -> Result<Vec<Sandbox>, String> {
478 info!(
479 namespace = %self.config.namespace,
480 "Listing sandboxes from Kubernetes"
481 );
482
483 let agent_sandbox_api = self
484 .supported_agent_sandbox_api(self.client.clone())
485 .await?;
486 match tokio::time::timeout(
487 KUBE_API_TIMEOUT,
488 agent_sandbox_api.api.list(&ListParams::default()),
489 )
490 .await
491 {
492 Ok(Ok(list)) => {
493 let mut sandboxes = list
494 .items
495 .into_iter()
496 .map(|obj| sandbox_from_object(&self.config.namespace, obj))
497 .collect::<Result<Vec<_>, _>>()?;
498 sandboxes.sort_by(|left, right| {
499 left.name
500 .cmp(&right.name)
501 .then_with(|| left.id.cmp(&right.id))
502 });
503 Ok(sandboxes)
504 }
505 Ok(Err(err)) => {
506 warn!(
507 namespace = %self.config.namespace,
508 error = %err,
509 "Failed to list sandboxes from Kubernetes"
510 );
511 Err(err.to_string())
512 }
513 Err(_elapsed) => {
514 warn!(
515 namespace = %self.config.namespace,
516 timeout_secs = KUBE_API_TIMEOUT.as_secs(),
517 "Timed out listing sandboxes from Kubernetes"
518 );
519 Err(format!(
520 "timed out after {}s waiting for Kubernetes API",
521 KUBE_API_TIMEOUT.as_secs()
522 ))
523 }
524 }
525 }
526
527 #[allow(clippy::similar_names)]
528 pub async fn create_sandbox(&self, sandbox: &Sandbox) -> Result<(), KubernetesDriverError> {

Callers

nothing calls this directly

Calls 3

sandbox_from_objectFunction · 0.85
listMethod · 0.45

Tested by

no test coverage detected