diff options
author | OpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com> | 2019-10-04 07:30:27 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-10-04 07:30:27 -0700 |
commit | c9e936a40796824422011515f2fe445f93451f31 (patch) | |
tree | fdab943f3efda62d030e42f7347cf02d7caa3943 /pkg/adapter/containers.go | |
parent | 1fe955600979f54ada204afa6c357fd094d6f549 (diff) | |
parent | dacbc5beb2a8841e52cf8ea7f544b4d302469c1d (diff) | |
download | podman-c9e936a40796824422011515f2fe445f93451f31.tar.gz podman-c9e936a40796824422011515f2fe445f93451f31.tar.bz2 podman-c9e936a40796824422011515f2fe445f93451f31.zip |
Merge pull request #3549 from marcov/evict-container
Add ability to evict a container
Diffstat (limited to 'pkg/adapter/containers.go')
-rw-r--r-- | pkg/adapter/containers.go | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/pkg/adapter/containers.go b/pkg/adapter/containers.go index 47db5c0dc..afca4c948 100644 --- a/pkg/adapter/containers.go +++ b/pkg/adapter/containers.go @@ -205,7 +205,22 @@ func (r *LocalRuntime) RemoveContainers(ctx context.Context, cli *cliconfig.RmVa ctrs, err := shortcuts.GetContainersByContext(cli.All, cli.Latest, cli.InputArgs, r.Runtime) if err != nil { - return ok, failures, err + // Failed to get containers. If force is specified, get the containers ID + // and evict them + if !cli.Force { + return ok, failures, err + } + + for _, ctr := range cli.InputArgs { + logrus.Debugf("Evicting container %q", ctr) + id, err := r.EvictContainer(ctx, ctr, cli.Volumes) + if err != nil { + failures[ctr] = errors.Wrapf(err, "Failed to evict container: %q", id) + continue + } + ok = append(ok, id) + } + return ok, failures, nil } pool := shared.NewPool("rm", maxWorkers, len(ctrs)) |