summaryrefslogtreecommitdiff
path: root/pkg/domain
diff options
context:
space:
mode:
authorDaniel J Walsh <dwalsh@redhat.com>2020-05-21 15:00:38 -0400
committerDaniel J Walsh <dwalsh@redhat.com>2020-05-21 15:17:28 -0400
commitb0b153ddcd7421201bdea989612a7c8b658de73a (patch)
treeeb1fb6ce5273e18d00384c54c639730393bf48af /pkg/domain
parent9d3b46624b4eb3b6eeea38b5b1057914a9ff2baf (diff)
downloadpodman-b0b153ddcd7421201bdea989612a7c8b658de73a.tar.gz
podman-b0b153ddcd7421201bdea989612a7c8b658de73a.tar.bz2
podman-b0b153ddcd7421201bdea989612a7c8b658de73a.zip
Fix podman-remote stop --all to handle not running containers
Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
Diffstat (limited to 'pkg/domain')
-rw-r--r--pkg/domain/infra/tunnel/containers.go23
1 files changed, 19 insertions, 4 deletions
diff --git a/pkg/domain/infra/tunnel/containers.go b/pkg/domain/infra/tunnel/containers.go
index d02c54e76..5b2c779b7 100644
--- a/pkg/domain/infra/tunnel/containers.go
+++ b/pkg/domain/infra/tunnel/containers.go
@@ -87,10 +87,25 @@ func (ic *ContainerEngine) ContainerStop(ctx context.Context, namesOrIds []strin
}
for _, c := range ctrs {
report := entities.StopReport{Id: c.ID}
- report.Err = containers.Stop(ic.ClientCxt, c.ID, &options.Timeout)
- // TODO we need to associate errors returned by http with common
- // define.errors so that we can equity tests. this will allow output
- // to be the same as the native client
+ if err = containers.Stop(ic.ClientCxt, c.ID, &options.Timeout); err != nil {
+ // These first two are considered non-fatal under the right conditions
+ if errors.Cause(err).Error() == define.ErrCtrStopped.Error() {
+ logrus.Debugf("Container %s is already stopped", c.ID)
+ reports = append(reports, &report)
+ continue
+ } else if options.All && errors.Cause(err).Error() == define.ErrCtrStateInvalid.Error() {
+ logrus.Debugf("Container %s is not running, could not stop", c.ID)
+ reports = append(reports, &report)
+ continue
+ }
+
+ // TODO we need to associate errors returned by http with common
+ // define.errors so that we can equity tests. this will allow output
+ // to be the same as the native client
+ report.Err = err
+ reports = append(reports, &report)
+ continue
+ }
reports = append(reports, &report)
}
return reports, nil