From 76c7f6c1a68eb5b0b95dbb3fd4be1dc5cec19758 Mon Sep 17 00:00:00 2001 From: David Scott Date: Fri, 24 Jul 2020 14:02:23 +0100 Subject: [PATCH] trim-after-delete: also handle containers and volumes We already run the command after an image delete but - a container delete - a volume delete will also free space on the filesystem. Co-authored-by: Sebastiaan van Stijn Signed-off-by: David Scott --- pkg/trim-after-delete/main.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/pkg/trim-after-delete/main.go b/pkg/trim-after-delete/main.go index d4cf49af5..bbcb154d0 100644 --- a/pkg/trim-after-delete/main.go +++ b/pkg/trim-after-delete/main.go @@ -15,7 +15,7 @@ import ( "time" ) -// Listen for Docker image delete events and run a command after a delay. +// Listen for Docker image, container, and volume delete events and run a command after a delay. // Event represents the subset of the Docker event message that we're // interested in @@ -136,7 +136,13 @@ RECONNECT: continue RECONNECT } if event.Action == "delete" && event.Type == "image" { - log.Printf("The delayed action will happen at least once more") + log.Printf("An image has been removed: will run the action at least once more") + action.AtLeastOnceMore() + } else if event.Action == "destroy" && event.Type == "container" { + log.Printf("A container has been removed: will run the action at least once more") + action.AtLeastOnceMore() + } else if event.Action == "destroy" && event.Type == "volume" { + log.Printf("A volume has been removed: will run the action at least once more") action.AtLeastOnceMore() } }