summaryrefslogtreecommitdiff
path: root/cmd
diff options
context:
space:
mode:
authorbaude <bbaude@redhat.com>2018-10-22 10:46:41 -0500
committerbaude <bbaude@redhat.com>2018-10-22 17:07:42 -0500
commit6362158615e9bc985efcc2af6d5119df3d073f64 (patch)
treebabc586ddbe668478386d79d16033f5374444fac /cmd
parent5b2478ed87eedd8178c1672a786f95a6716a8edb (diff)
downloadpodman-6362158615e9bc985efcc2af6d5119df3d073f64.tar.gz
podman-6362158615e9bc985efcc2af6d5119df3d073f64.tar.bz2
podman-6362158615e9bc985efcc2af6d5119df3d073f64.zip
correct stats err with non-running containers
when doing stats -a|--all, if you have non-running containers, we should not error on not being able to get information like PID, etc on them. Signed-off-by: baude <bbaude@redhat.com>
Diffstat (limited to 'cmd')
-rw-r--r--cmd/podman/stats.go7
1 files changed, 5 insertions, 2 deletions
diff --git a/cmd/podman/stats.go b/cmd/podman/stats.go
index dea351e88..f6beac1a8 100644
--- a/cmd/podman/stats.go
+++ b/cmd/podman/stats.go
@@ -84,8 +84,7 @@ func statsCmd(c *cli.Context) error {
if ctr > 1 {
return errors.Errorf("--all, --latest and containers cannot be used together")
} else if ctr == 0 {
- // If user didn't specify, imply --all
- all = true
+ return errors.Errorf("you must specify --all, --latest, or at least one container")
}
runtime, err := libpodruntime.GetRuntime(c)
@@ -126,6 +125,10 @@ func statsCmd(c *cli.Context) error {
for _, ctr := range ctrs {
initialStats, err := ctr.GetContainerStats(&libpod.ContainerStats{})
if err != nil {
+ // when doing "all", dont worry about containers that are not running
+ if c.Bool("all") && errors.Cause(err) == libpod.ErrCtrRemoved || errors.Cause(err) == libpod.ErrNoSuchCtr || errors.Cause(err) == libpod.ErrCtrStateInvalid {
+ continue
+ }
return err
}
containerStats[ctr.ID()] = initialStats