(&self, name: &str)
| 645 | } |
| 646 | |
| 647 | pub async fn delete_sandbox(&self, name: &str) -> Result<bool, String> { |
| 648 | info!( |
| 649 | sandbox_name = %name, |
| 650 | namespace = %self.config.namespace, |
| 651 | "Deleting sandbox from Kubernetes" |
| 652 | ); |
| 653 | |
| 654 | let agent_sandbox_api = self |
| 655 | .supported_agent_sandbox_api(self.client.clone()) |
| 656 | .await?; |
| 657 | match tokio::time::timeout( |
| 658 | KUBE_API_TIMEOUT, |
| 659 | agent_sandbox_api.api.delete(name, &DeleteParams::default()), |
| 660 | ) |
| 661 | .await |
| 662 | { |
| 663 | Ok(Ok(_response)) => { |
| 664 | info!(sandbox_name = %name, "Sandbox deleted from Kubernetes"); |
| 665 | Ok(true) |
| 666 | } |
| 667 | Ok(Err(KubeError::Api(err))) if err.code == 404 => { |
| 668 | debug!(sandbox_name = %name, "Sandbox not found in Kubernetes (already deleted)"); |
| 669 | Ok(false) |
| 670 | } |
| 671 | Ok(Err(err)) => { |
| 672 | warn!( |
| 673 | sandbox_name = %name, |
| 674 | error = %err, |
| 675 | "Failed to delete sandbox from Kubernetes" |
| 676 | ); |
| 677 | Err(err.to_string()) |
| 678 | } |
| 679 | Err(_elapsed) => { |
| 680 | warn!( |
| 681 | sandbox_name = %name, |
| 682 | timeout_secs = KUBE_API_TIMEOUT.as_secs(), |
| 683 | "Timed out deleting sandbox from Kubernetes" |
| 684 | ); |
| 685 | Err(format!( |
| 686 | "timed out after {}s waiting for Kubernetes API", |
| 687 | KUBE_API_TIMEOUT.as_secs() |
| 688 | )) |
| 689 | } |
| 690 | } |
| 691 | } |
| 692 | |
| 693 | pub async fn sandbox_exists(&self, name: &str) -> Result<bool, String> { |
| 694 | let agent_sandbox_api = self |
nothing calls this directly
no test coverage detected