From 4319552cf89e72925a80c63f427e5ef0a6376046 Mon Sep 17 00:00:00 2001 From: Peter Hunt Date: Mon, 15 Apr 2019 15:44:32 -0400 Subject: Added remote pod prune Signed-off-by: Peter Hunt --- cmd/podman/pods_prune.go | 12 ++---------- cmd/podman/varlink/io.podman.varlink | 3 +++ 2 files changed, 5 insertions(+), 10 deletions(-) (limited to 'cmd') diff --git a/cmd/podman/pods_prune.go b/cmd/podman/pods_prune.go index 4ffe6fc27..89401a98a 100644 --- a/cmd/podman/pods_prune.go +++ b/cmd/podman/pods_prune.go @@ -5,7 +5,6 @@ import ( "github.com/containers/libpod/cmd/podman/cliconfig" "github.com/containers/libpod/cmd/podman/shared" - "github.com/containers/libpod/libpod" "github.com/containers/libpod/pkg/adapter" "github.com/pkg/errors" "github.com/sirupsen/logrus" @@ -43,15 +42,8 @@ func init() { func prunePods(runtime *adapter.LocalRuntime, ctx context.Context, maxWorkers int, force bool) error { var deleteFuncs []shared.ParallelWorkerInput - filter := func(p *libpod.Pod) bool { - state, err := shared.GetPodStatus(p) - // pod states should be the same - if state == shared.PodStateStopped || (state == shared.PodStateExited && err == nil) { - return true - } - return false - } - delPods, err := runtime.Pods(filter) + states := []string{shared.PodStateStopped, shared.PodStateExited} + delPods, err := runtime.GetPodsByStatus(states) if err != nil { return err } diff --git a/cmd/podman/varlink/io.podman.varlink b/cmd/podman/varlink/io.podman.varlink index b5295273a..497f130bc 100644 --- a/cmd/podman/varlink/io.podman.varlink +++ b/cmd/podman/varlink/io.podman.varlink @@ -1053,6 +1053,9 @@ method TopPod(pod: string, latest: bool, descriptors: []string) -> (stats: []str # ~~~ method GetPodStats(name: string) -> (pod: string, containers: []ContainerStats) +# GetPodsByStatus searches for pods whose status is included in statuses +method GetPodsByStatus(statuses: []string) -> (pods: []string) + # ImageExists talks a full or partial image ID or name and returns an int as to whether # the image exists in local storage. An int result of 0 means the image does exist in # local storage; whereas 1 indicates the image does not exists in local storage. -- cgit v1.2.3-54-g00ecf