(&self, name: &str)
| 437 | } |
| 438 | |
| 439 | pub async fn get_sandbox(&self, name: &str) -> Result<Option<Sandbox>, String> { |
| 440 | info!( |
| 441 | sandbox_name = %name, |
| 442 | namespace = %self.config.namespace, |
| 443 | "Fetching sandbox from Kubernetes" |
| 444 | ); |
| 445 | |
| 446 | let agent_sandbox_api = self |
| 447 | .supported_agent_sandbox_api(self.client.clone()) |
| 448 | .await?; |
| 449 | match tokio::time::timeout(KUBE_API_TIMEOUT, agent_sandbox_api.api.get(name)).await { |
| 450 | Ok(Ok(obj)) => sandbox_from_object(&self.config.namespace, obj).map(Some), |
| 451 | Ok(Err(KubeError::Api(err))) if err.code == 404 => { |
| 452 | debug!(sandbox_name = %name, "Sandbox not found in Kubernetes"); |
| 453 | Ok(None) |
| 454 | } |
| 455 | Ok(Err(err)) => { |
| 456 | warn!( |
| 457 | sandbox_name = %name, |
| 458 | error = %err, |
| 459 | "Failed to fetch sandbox from Kubernetes" |
| 460 | ); |
| 461 | Err(err.to_string()) |
| 462 | } |
| 463 | Err(_elapsed) => { |
| 464 | warn!( |
| 465 | sandbox_name = %name, |
| 466 | timeout_secs = KUBE_API_TIMEOUT.as_secs(), |
| 467 | "Timed out fetching sandbox from Kubernetes" |
| 468 | ); |
| 469 | Err(format!( |
| 470 | "timed out after {}s waiting for Kubernetes API", |
| 471 | KUBE_API_TIMEOUT.as_secs() |
| 472 | )) |
| 473 | } |
| 474 | } |
| 475 | } |
| 476 | |
| 477 | pub async fn list_sandboxes(&self) -> Result<Vec<Sandbox>, String> { |
| 478 | info!( |
nothing calls this directly
no test coverage detected