diff options
| author | Brian Goff <cpuguy83@gmail.com> | 2022-09-28 19:43:45 +0000 |
|---|---|---|
| committer | Brian Goff <cpuguy83@gmail.com> | 2022-10-04 20:55:13 +0000 |
| commit | 618f26ccbc3b5c314680dae4b09f5d13f9c02570 (patch) | |
| tree | bc2c55a73e46d8aa8f4969fce7993724a4630933 /api | |
| parent | 8d193d81af9cbbe800475d4bb8c529d67a6d8f14 (diff) | |
| download | docker-618f26ccbc3b5c314680dae4b09f5d13f9c02570.tar.gz | |
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 <cpuguy83@gmail.com>
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Diffstat (limited to 'api')
| -rw-r--r-- | api/server/router/volume/volume_routes.go | 6 | ||||
| -rw-r--r-- | api/swagger.yaml | 1 |
2 files changed, 7 insertions, 0 deletions
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 diff --git a/api/swagger.yaml b/api/swagger.yaml index 320c12e293..bcaf549e1f 100644 --- a/api/swagger.yaml +++ b/api/swagger.yaml @@ -9700,6 +9700,7 @@ paths: Available filters: - `label` (`label=<key>`, `label=<key>=<value>`, `label!=<key>`, or `label!=<key>=<value>`) Prune volumes with (or without, in case `label!=...` is used) the specified labels. + - `all` (`all=true`) - Consider all (local) volumes for pruning and not just anonymous volumes. type: "string" responses: 200: |
