From 77a1665c05517194c4d5b27b7e03326d4c0923c9 Mon Sep 17 00:00:00 2001 From: baude Date: Mon, 9 Apr 2018 08:55:39 -0500 Subject: Containers transitioning to stop should not break stats When a container is transitioning from running to stopped and stats is runnings, we should not break stats if we are unable to get stats for that container. Resolves: #598 Signed-off-by: baude Closes: #599 Approved by: mheon --- cmd/podman/stats.go | 2 +- libpod/stats.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/cmd/podman/stats.go b/cmd/podman/stats.go index 3c2dfb5cf..6a8681028 100644 --- a/cmd/podman/stats.go +++ b/cmd/podman/stats.go @@ -140,7 +140,7 @@ func statsCmd(c *cli.Context) error { containerStats[id] = initialStats } stats, err := ctr.GetContainerStats(containerStats[id]) - if err != nil { + if err != nil && errors.Cause(err) != libpod.ErrNoSuchCtr { return err } // replace the previous measurement with the current one diff --git a/libpod/stats.go b/libpod/stats.go index f4694923c..33e57572c 100644 --- a/libpod/stats.go +++ b/libpod/stats.go @@ -37,7 +37,7 @@ func (c *Container) GetContainerStats(previousStats *ContainerStats) (*Container c.lock.Lock() defer c.lock.Unlock() if err := c.syncContainer(); err != nil { - return stats, errors.Wrapf(err, "error updating container %s state", c.ID()) + return stats, err } if c.state.State != ContainerStateRunning { return stats, nil -- cgit v1.2.3-54-g00ecf