From b4754b64d549610cff8c27b4655003fe8399e1eb Mon Sep 17 00:00:00 2001 From: mbecker20 Date: Wed, 3 Apr 2024 00:28:58 -0700 Subject: [PATCH] improve PruneAll using docker system prune -a -f --- bin/periphery/src/api/mod.rs | 12 ++---------- bin/periphery/src/helpers/docker/mod.rs | 5 +++++ client/periphery/rs/src/api/mod.rs | 2 +- 3 files changed, 8 insertions(+), 11 deletions(-) diff --git a/bin/periphery/src/api/mod.rs b/bin/periphery/src/api/mod.rs index 7c8e89bff..b523c2dd7 100644 --- a/bin/periphery/src/api/mod.rs +++ b/bin/periphery/src/api/mod.rs @@ -156,15 +156,7 @@ impl Resolve for State { &self, PruneAll {}: PruneAll, _: (), - ) -> anyhow::Result> { - tokio::spawn(async move { - let mut logs = Vec::new(); - logs.push(docker::prune_images().await); - logs.push(docker::container::prune_containers().await); - logs.push(docker::network::prune_networks().await); - logs - }) - .await - .context("failure in spawned task") + ) -> anyhow::Result { + Ok(docker::prune_system().await) } } diff --git a/bin/periphery/src/helpers/docker/mod.rs b/bin/periphery/src/helpers/docker/mod.rs index bb6931c5c..903fa4b47 100644 --- a/bin/periphery/src/helpers/docker/mod.rs +++ b/bin/periphery/src/helpers/docker/mod.rs @@ -52,3 +52,8 @@ pub fn parse_extra_args(extra_args: &[String]) -> String { args } } + +pub async fn prune_system() -> Log { + let command = String::from("docker system prune -a -f"); + run_monitor_command("prune system", command).await +} diff --git a/client/periphery/rs/src/api/mod.rs b/client/periphery/rs/src/api/mod.rs index fd92fcf04..ffb3604bd 100644 --- a/client/periphery/rs/src/api/mod.rs +++ b/client/periphery/rs/src/api/mod.rs @@ -49,7 +49,7 @@ pub struct GetSecrets {} // #[derive(Serialize, Deserialize, Debug, Clone, Request)] -#[response(Vec)] +#[response(Log)] pub struct PruneAll {} //