diff --git a/pkg/api/handlers/compat/volumes.go b/pkg/api/handlers/compat/volumes.go index 943190841b..9ddda58a04 100644 --- a/pkg/api/handlers/compat/volumes.go +++ b/pkg/api/handlers/compat/volumes.go @@ -60,6 +60,9 @@ func ListVolumes(w http.ResponseWriter, r *http.Request) { for _, v := range vols { mp, err := v.MountPoint() if err != nil { + if errors.Is(err, define.ErrNoSuchVolume) { + continue + } utils.InternalServerError(w, err) return } diff --git a/pkg/api/handlers/libpod/volumes.go b/pkg/api/handlers/libpod/volumes.go index 986052e924..545f3b3f55 100644 --- a/pkg/api/handlers/libpod/volumes.go +++ b/pkg/api/handlers/libpod/volumes.go @@ -121,33 +121,13 @@ func ListVolumes(w http.ResponseWriter, r *http.Request) { return } - volumeFilters := []libpod.VolumeFilter{} - for filter, filterValues := range *filterMap { - filterFunc, err := filters.GenerateVolumeFilters(filter, filterValues, runtime) - if err != nil { - utils.InternalServerError(w, err) - return - } - volumeFilters = append(volumeFilters, filterFunc) - } - - vols, err := runtime.Volumes(volumeFilters...) + ic := abi.ContainerEngine{Libpod: runtime} + volumeConfigs, err := ic.VolumeList(r.Context(), entities.VolumeListOptions{Filter: *filterMap}) if err != nil { utils.InternalServerError(w, err) return } - volumeConfigs := make([]*entities.VolumeListReport, 0, len(vols)) - for _, v := range vols { - inspectOut, err := v.Inspect() - if err != nil { - utils.InternalServerError(w, err) - return - } - config := entities.VolumeConfigResponse{ - InspectVolumeData: *inspectOut, - } - volumeConfigs = append(volumeConfigs, &entities.VolumeListReport{VolumeConfigResponse: config}) - } + utils.WriteResponse(w, http.StatusOK, volumeConfigs) } diff --git a/pkg/domain/infra/abi/volumes.go b/pkg/domain/infra/abi/volumes.go index 7ecc29324f..77c99559e5 100644 --- a/pkg/domain/infra/abi/volumes.go +++ b/pkg/domain/infra/abi/volumes.go @@ -164,6 +164,9 @@ func (ic *ContainerEngine) VolumeList(ctx context.Context, opts entities.VolumeL for _, v := range vols { inspectOut, err := v.Inspect() if err != nil { + if errors.Is(err, define.ErrNoSuchVolume) { + continue + } return nil, err } config := entities.VolumeConfigResponse{