diff options
author | OpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com> | 2018-10-25 13:08:45 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-10-25 13:08:45 -0700 |
commit | f6e7807fa5970f328c1221c2e0c0aafe5f1c4b34 (patch) | |
tree | 91e518a3653694f50ae4b9a9f3b3423b2ff968e6 /cmd/podman/stop.go | |
parent | 3efa0685289a44ab21015897253565b9c50c1777 (diff) | |
parent | 3e5a5c68da9884ddb46cb9e84435956996347a4b (diff) | |
download | podman-f6e7807fa5970f328c1221c2e0c0aafe5f1c4b34.tar.gz podman-f6e7807fa5970f328c1221c2e0c0aafe5f1c4b34.tar.bz2 podman-f6e7807fa5970f328c1221c2e0c0aafe5f1c4b34.zip |
Merge pull request #1709 from baude/parallelheur
Add --max-workers and heuristics for parallel operations
Diffstat (limited to 'cmd/podman/stop.go')
-rw-r--r-- | cmd/podman/stop.go | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/cmd/podman/stop.go b/cmd/podman/stop.go index edadbda89..afeb49f76 100644 --- a/cmd/podman/stop.go +++ b/cmd/podman/stop.go @@ -2,12 +2,12 @@ package main import ( "fmt" - rt "runtime" - "github.com/containers/libpod/cmd/podman/libpodruntime" + "github.com/containers/libpod/cmd/podman/shared" "github.com/containers/libpod/libpod" "github.com/containers/libpod/pkg/rootless" "github.com/pkg/errors" + "github.com/sirupsen/logrus" "github.com/urfave/cli" ) @@ -61,7 +61,7 @@ func stopCmd(c *cli.Context) error { containers, lastError := getAllOrLatestContainers(c, runtime, libpod.ContainerStateRunning, "running") - var stopFuncs []workerInput + var stopFuncs []shared.ParallelWorkerInput for _, ctr := range containers { con := ctr var stopTimeout uint @@ -73,13 +73,19 @@ func stopCmd(c *cli.Context) error { f := func() error { return con.StopWithTimeout(stopTimeout) } - stopFuncs = append(stopFuncs, workerInput{ - containerID: con.ID(), - parallelFunc: f, + stopFuncs = append(stopFuncs, shared.ParallelWorkerInput{ + ContainerID: con.ID(), + ParallelFunc: f, }) } - stopErrors := parallelExecuteWorkerPool(rt.NumCPU()*3, stopFuncs) + maxWorkers := shared.Parallelize("stop") + if c.GlobalIsSet("max-workers") { + maxWorkers = c.GlobalInt("max-workers") + } + logrus.Debugf("Setting maximum workers to %d", maxWorkers) + + stopErrors := shared.ParallelExecuteWorkerPool(maxWorkers, stopFuncs) for cid, result := range stopErrors { if result != nil && result != libpod.ErrCtrStopped { |