List all managed sandboxes. Only inspects running containers (to get health status). Non-running containers are built directly from the list entry data.
(&self)
| 729 | /// Only inspects running containers (to get health status). Non-running |
| 730 | /// containers are built directly from the list entry data. |
| 731 | pub async fn list_sandboxes(&self) -> Result<Vec<DriverSandbox>, ComputeDriverError> { |
| 732 | let entries = self |
| 733 | .client |
| 734 | .list_containers(LABEL_MANAGED_FILTER) |
| 735 | .await |
| 736 | .map_err(ComputeDriverError::from)?; |
| 737 | |
| 738 | let mut sandboxes = Vec::with_capacity(entries.len()); |
| 739 | for entry in &entries { |
| 740 | if entry.state == "running" { |
| 741 | // Running containers need inspect for health check status. |
| 742 | match self.client.inspect_container(&entry.id).await { |
| 743 | Ok(inspect) => { |
| 744 | if let Some(sandbox) = driver_sandbox_from_inspect(&inspect) { |
| 745 | sandboxes.push(sandbox); |
| 746 | continue; |
| 747 | } |
| 748 | } |
| 749 | Err(e) => { |
| 750 | let name = entry.names.first().cloned().unwrap_or_default(); |
| 751 | warn!( |
| 752 | container = %name, |
| 753 | error = %e, |
| 754 | "Failed to inspect running container during list, falling back to list entry" |
| 755 | ); |
| 756 | } |
| 757 | } |
| 758 | } |
| 759 | // Non-running containers (or inspect fallback): build from list data. |
| 760 | if let Some(sandbox) = driver_sandbox_from_list_entry(entry) { |
| 761 | sandboxes.push(sandbox); |
| 762 | } |
| 763 | } |
| 764 | |
| 765 | sandboxes.sort_by(|a, b| a.name.cmp(&b.name).then_with(|| a.id.cmp(&b.id))); |
| 766 | Ok(sandboxes) |
| 767 | } |
| 768 | |
| 769 | /// Start watching all managed sandbox containers. |
| 770 | pub async fn watch_sandboxes(&self) -> Result<WatchStream, ComputeDriverError> { |
no test coverage detected