From 618f26ccbc3b5c314680dae4b09f5d13f9c02570 Mon Sep 17 00:00:00 2001 From: Brian Goff Date: Wed, 28 Sep 2022 19:43:45 +0000 Subject: Volume prune: only prune anonymous volumes by default This adds a new filter argument to the volume prune endpoint "all". When this is not set, or it is a false-y value, then only anonymous volumes are considered for pruning. When `all` is set to a truth-y value, you get the old behavior. This is an API change, but I think one that is what most people would want. Signed-off-by: Brian Goff Signed-off-by: Sebastiaan van Stijn --- api/server/router/volume/volume_routes.go | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'api/server') diff --git a/api/server/router/volume/volume_routes.go b/api/server/router/volume/volume_routes.go index 7f1adfaa78..6fd5097c8b 100644 --- a/api/server/router/volume/volume_routes.go +++ b/api/server/router/volume/volume_routes.go @@ -187,6 +187,12 @@ func (v *volumeRouter) postVolumesPrune(ctx context.Context, w http.ResponseWrit return err } + // API version 1.42 changes behavior where prune should only prune anonymous volumes. + // To keep older API behavior working, we need to add this filter option to consider all (local) volumes for pruning, not just anonymous ones. + if versions.LessThan(httputils.VersionFromContext(ctx), "1.42") { + pruneFilters.Add("all", "true") + } + pruneReport, err := v.backend.Prune(ctx, pruneFilters) if err != nil { return err -- cgit v1.2.1