diff options
author | haircommander <pehunt@redhat.com> | 2018-08-22 13:13:07 -0400 |
---|---|---|
committer | Atomic Bot <atomic-devel@projectatomic.io> | 2018-08-23 15:58:08 +0000 |
commit | 63dd200e7e47261454c7e55fed2ad972144e147f (patch) | |
tree | 3c18d6c844801a5ebaa01e6359c492fd325aef66 /libpod/pod.go | |
parent | 3df6332a65b203b8fab106e9856a263f24b956a0 (diff) | |
download | podman-63dd200e7e47261454c7e55fed2ad972144e147f.tar.gz podman-63dd200e7e47261454c7e55fed2ad972144e147f.tar.bz2 podman-63dd200e7e47261454c7e55fed2ad972144e147f.zip |
Changed GetContainerStats to return ErrCtrStateInvalid
This results in some functionality changes:
If a ErrCtrStateInvalid is returned to GetPodStats, the container is ommitted from the stats.
As such, if an empty slice of Container stats are returned to GetPodStats in varlink, an error will occur.
GetContainerStats will return the ErrCtrStateInvalid as well.
Finally, if ErrCtrStateInvalid is returned to the podman stats call, the container will be ommitted from the stats.
Signed-off-by: haircommander <pehunt@redhat.com>
Closes: #1319
Approved by: baude
Diffstat (limited to 'libpod/pod.go')
-rw-r--r-- | libpod/pod.go | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/libpod/pod.go b/libpod/pod.go index e5d491e52..666480aa8 100644 --- a/libpod/pod.go +++ b/libpod/pod.go @@ -4,6 +4,7 @@ import ( "time" "github.com/containers/storage" + "github.com/pkg/errors" ) // Pod represents a group of containers that are managed together. @@ -192,10 +193,14 @@ func (p *Pod) GetPodStats(previousContainerStats map[string]*ContainerStats) (ma prevStat = &ContainerStats{} } newStats, err := c.GetContainerStats(prevStat) - if err != nil { + // If the container wasn't running, don't include it + // but also suppress the error + if err != nil && errors.Cause(err) != ErrCtrStateInvalid { return nil, err } - newContainerStats[c.ID()] = newStats + if err == nil { + newContainerStats[c.ID()] = newStats + } } return newContainerStats, nil } |