diff options
author | OpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com> | 2021-01-08 06:56:15 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-01-08 06:56:15 -0500 |
commit | a0b432d29d18c7385c2c976249bdc4eec95d335a (patch) | |
tree | 9e40297a48967cb64d2f3325f9ee15b3ea31aa7f /pkg/api/handlers/compat/volumes.go | |
parent | 78cda71372485f163909525f8d07194920968486 (diff) | |
parent | b059e1044f5a1bac6a531e6241e24f82c8c6a9c0 (diff) | |
download | podman-a0b432d29d18c7385c2c976249bdc4eec95d335a.tar.gz podman-a0b432d29d18c7385c2c976249bdc4eec95d335a.tar.bz2 podman-a0b432d29d18c7385c2c976249bdc4eec95d335a.zip |
Merge pull request #8912 from jwhonce/issues/8891
Restore compatible API for prune endpoints
Diffstat (limited to 'pkg/api/handlers/compat/volumes.go')
-rw-r--r-- | pkg/api/handlers/compat/volumes.go | 28 |
1 files changed, 21 insertions, 7 deletions
diff --git a/pkg/api/handlers/compat/volumes.go b/pkg/api/handlers/compat/volumes.go index 1188d8f84..4903bbad4 100644 --- a/pkg/api/handlers/compat/volumes.go +++ b/pkg/api/handlers/compat/volumes.go @@ -1,6 +1,7 @@ package compat import ( + "bytes" "encoding/json" "net/http" "net/url" @@ -8,6 +9,7 @@ import ( "github.com/containers/podman/v2/libpod" "github.com/containers/podman/v2/libpod/define" + "github.com/containers/podman/v2/pkg/api/handlers" "github.com/containers/podman/v2/pkg/api/handlers/utils" "github.com/containers/podman/v2/pkg/domain/filters" "github.com/containers/podman/v2/pkg/domain/infra/abi/parse" @@ -268,17 +270,29 @@ func PruneVolumes(w http.ResponseWriter, r *http.Request) { utils.InternalServerError(w, err) return } + + var errorMsg bytes.Buffer + var reclaimedSpace uint64 prunedIds := make([]string, 0, len(pruned)) for _, v := range pruned { - // XXX: This drops any pruning per-volume error messages on the floor + if v.Err != nil { + errorMsg.WriteString(v.Err.Error()) + errorMsg.WriteString("; ") + continue + } prunedIds = append(prunedIds, v.Id) + reclaimedSpace += v.Size } - pruneResponse := docker_api_types.VolumesPruneReport{ - VolumesDeleted: prunedIds, - // TODO: We don't have any insight into how much space was reclaimed - // from `PruneVolumes()` but it's not nullable - SpaceReclaimed: 0, + if errorMsg.Len() > 0 { + utils.InternalServerError(w, errors.New(errorMsg.String())) + return } - utils.WriteResponse(w, http.StatusOK, pruneResponse) + payload := handlers.VolumesPruneReport{ + VolumesPruneReport: docker_api_types.VolumesPruneReport{ + VolumesDeleted: prunedIds, + SpaceReclaimed: reclaimedSpace, + }, + } + utils.WriteResponse(w, http.StatusOK, payload) } |