Cleans up an agent's network after task completion. Disconnects the proxy from the network and removes it. Logs warnings on failure but does not return errors (cleanup is best-effort).
(
&self,
proxy_container_name: &str,
network_name: &str,
)
| 766 | /// Disconnects the proxy from the network and removes it. |
| 767 | /// Logs warnings on failure but does not return errors (cleanup is best-effort). |
| 768 | pub(crate) async fn cleanup_agent_network( |
| 769 | &self, |
| 770 | proxy_container_name: &str, |
| 771 | network_name: &str, |
| 772 | ) { |
| 773 | // Disconnect proxy from network |
| 774 | if let Err(e) = self |
| 775 | .docker_client |
| 776 | .disconnect_container_from_network(proxy_container_name, network_name) |
| 777 | .await |
| 778 | { |
| 779 | self.emit(ServerEvent::WarningMessage(format!( |
| 780 | "Warning: Failed to disconnect proxy from network {network_name}: {e}" |
| 781 | ))); |
| 782 | } |
| 783 | |
| 784 | // Remove the network |
| 785 | if let Err(e) = self.docker_client.remove_network(network_name).await { |
| 786 | self.emit(ServerEvent::WarningMessage(format!( |
| 787 | "Warning: Failed to remove network {network_name}: {e}" |
| 788 | ))); |
| 789 | } |
| 790 | } |
| 791 | |
| 792 | /// Gets the network name for a specific agent task |
| 793 | /// |