diff options
author | OpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com> | 2020-06-05 12:27:25 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-06-05 12:27:25 -0400 |
commit | c448c03269139dabf6f6fa7ff0fedb2291018b2a (patch) | |
tree | a0270fa5403d5e42639dd1b71ea752444131eaaa /pkg/domain/infra | |
parent | c6da1a86cedfa04ea69886a4cb88ef1c570574b4 (diff) | |
parent | 89a1e7db39ed1015762d733379a4a5d443b1f4de (diff) | |
download | podman-c448c03269139dabf6f6fa7ff0fedb2291018b2a.tar.gz podman-c448c03269139dabf6f6fa7ff0fedb2291018b2a.tar.bz2 podman-c448c03269139dabf6f6fa7ff0fedb2291018b2a.zip |
Merge pull request #6495 from mheon/parallel_execution
Add parallel execution code for container operations
Diffstat (limited to 'pkg/domain/infra')
-rw-r--r-- | pkg/domain/infra/abi/containers.go | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/pkg/domain/infra/abi/containers.go b/pkg/domain/infra/abi/containers.go index 19232eff1..eb45d4630 100644 --- a/pkg/domain/infra/abi/containers.go +++ b/pkg/domain/infra/abi/containers.go @@ -23,6 +23,7 @@ import ( "github.com/containers/libpod/pkg/checkpoint" "github.com/containers/libpod/pkg/domain/entities" "github.com/containers/libpod/pkg/domain/infra/abi/terminal" + "github.com/containers/libpod/pkg/parallel" "github.com/containers/libpod/pkg/ps" "github.com/containers/libpod/pkg/rootless" "github.com/containers/libpod/pkg/signal" @@ -321,21 +322,25 @@ func (ic *ContainerEngine) ContainerRm(ctx context.Context, namesOrIds []string, return reports, nil } - for _, c := range ctrs { - report := entities.RmReport{Id: c.ID()} + errMap, err := parallel.ParallelContainerOp(ctx, ctrs, func(c *libpod.Container) error { err := ic.Libpod.RemoveContainer(ctx, c, options.Force, options.Volumes) if err != nil { if options.Ignore && errors.Cause(err) == define.ErrNoSuchCtr { logrus.Debugf("Ignoring error (--allow-missing): %v", err) - reports = append(reports, &report) - continue + return nil } logrus.Debugf("Failed to remove container %s: %s", c.ID(), err.Error()) - report.Err = err - reports = append(reports, &report) - continue } - reports = append(reports, &report) + return err + }) + if err != nil { + return nil, err + } + for ctr, err := range errMap { + report := new(entities.RmReport) + report.Id = ctr.ID() + report.Err = err + reports = append(reports, report) } return reports, nil } |