summaryrefslogtreecommitdiff
path: root/pkg/adapter/containers_remote.go
diff options
context:
space:
mode:
authorOpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com>2019-10-04 07:30:27 -0700
committerGitHub <noreply@github.com>2019-10-04 07:30:27 -0700
commitc9e936a40796824422011515f2fe445f93451f31 (patch)
treefdab943f3efda62d030e42f7347cf02d7caa3943 /pkg/adapter/containers_remote.go
parent1fe955600979f54ada204afa6c357fd094d6f549 (diff)
parentdacbc5beb2a8841e52cf8ea7f544b4d302469c1d (diff)
downloadpodman-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_remote.go')
-rw-r--r--pkg/adapter/containers_remote.go25
1 files changed, 20 insertions, 5 deletions
diff --git a/pkg/adapter/containers_remote.go b/pkg/adapter/containers_remote.go
index 6cecb92da..f7cb28b0c 100644
--- a/pkg/adapter/containers_remote.go
+++ b/pkg/adapter/containers_remote.go
@@ -321,16 +321,31 @@ func (r *LocalRuntime) KillContainers(ctx context.Context, cli *cliconfig.KillVa
// RemoveContainer removes container(s) based on varlink inputs.
func (r *LocalRuntime) RemoveContainers(ctx context.Context, cli *cliconfig.RmValues) ([]string, map[string]error, error) {
- ids, err := iopodman.GetContainersByContext().Call(r.Conn, cli.All, cli.Latest, cli.InputArgs)
- if err != nil {
- return nil, nil, TranslateError(err)
- }
-
var (
ok = []string{}
failures = map[string]error{}
)
+ ids, err := iopodman.GetContainersByContext().Call(r.Conn, cli.All, cli.Latest, cli.InputArgs)
+ if err != nil {
+ // Failed to get containers. If force is specified, get the containers ID
+ // and evict them
+ if !cli.Force {
+ return nil, nil, TranslateError(err)
+ }
+
+ for _, ctr := range cli.InputArgs {
+ logrus.Debugf("Evicting container %q", ctr)
+ id, err := iopodman.EvictContainer().Call(r.Conn, ctr, cli.Volumes)
+ if err != nil {
+ failures[ctr] = errors.Wrapf(err, "Failed to evict container: %q", id)
+ continue
+ }
+ ok = append(ok, string(id))
+ }
+ return ok, failures, nil
+ }
+
for _, id := range ids {
_, err := iopodman.RemoveContainer().Call(r.Conn, id, cli.Force, cli.Volumes)
if err != nil {