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 /pkg/varlinkapi | |
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 'pkg/varlinkapi')
-rw-r--r-- | pkg/varlinkapi/containers.go | 3 | ||||
-rw-r--r-- | pkg/varlinkapi/pods.go | 3 |
2 files changed, 6 insertions, 0 deletions
diff --git a/pkg/varlinkapi/containers.go b/pkg/varlinkapi/containers.go index 58452716a..f517e9b6e 100644 --- a/pkg/varlinkapi/containers.go +++ b/pkg/varlinkapi/containers.go @@ -207,6 +207,9 @@ func (i *LibpodAPI) GetContainerStats(call iopodman.VarlinkCall, name string) er } containerStats, err := ctr.GetContainerStats(&libpod.ContainerStats{}) if err != nil { + if errors.Cause(err) == libpod.ErrCtrStateInvalid { + return call.ReplyNoContainerRunning() + } return call.ReplyErrorOccurred(err.Error()) } cs := iopodman.ContainerStats{ diff --git a/pkg/varlinkapi/pods.go b/pkg/varlinkapi/pods.go index 75733db11..9e49ab687 100644 --- a/pkg/varlinkapi/pods.go +++ b/pkg/varlinkapi/pods.go @@ -199,6 +199,9 @@ func (i *LibpodAPI) GetPodStats(call iopodman.VarlinkCall, name string) error { if err != nil { return call.ReplyErrorOccurred(err.Error()) } + if len(podStats) == 0 { + return call.ReplyNoContainerRunning() + } containersStats := make([]iopodman.ContainerStats, 0) for ctrID, containerStats := range podStats { cs := iopodman.ContainerStats{ |