diff options
author | Jake Correnti <jcorrenti13@gmail.com> | 2022-06-13 13:33:19 -0400 |
---|---|---|
committer | Jake Correnti <jcorrenti13@gmail.com> | 2022-06-13 15:03:22 -0400 |
commit | 608ad7d1139d80093d1ddd933027d31af7fdee83 (patch) | |
tree | 16d53c9568b86faf520501466618b4df7b8cad1c /libpod | |
parent | 1ada01a038fceaa9e94beb2de6e4593df03be7fa (diff) | |
download | podman-608ad7d1139d80093d1ddd933027d31af7fdee83.tar.gz podman-608ad7d1139d80093d1ddd933027d31af7fdee83.tar.bz2 podman-608ad7d1139d80093d1ddd933027d31af7fdee83.zip |
Non-running containers now report statistics via the `podman stats`
command
Previously, if a container was not running, and the user ran the `podman
stats` command, an error would be reported: `Error: container state
improper`.
Podman now reports stats as the fields' default values for their
respective type if the container is not running:
```
$ podman stats --no-stream demo
ID NAME CPU % MEM USAGE / LIMIT MEM % NET IO BLOCK IO PIDS CPU TIME AVG CPU %
4b4bf8ce84ed demo 0.00% 0B / 0B 0.00% 0B / 0B 0B / 0B 0 0s 0.00%
```
Closes: #14498
Signed-off-by: Jake Correnti <jcorrenti13@gmail.com>
Diffstat (limited to 'libpod')
-rw-r--r-- | libpod/stats.go | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/libpod/stats.go b/libpod/stats.go index 25baa378d..d2ffc3b32 100644 --- a/libpod/stats.go +++ b/libpod/stats.go @@ -34,8 +34,9 @@ func (c *Container) GetContainerStats(previousStats *define.ContainerStats) (*de } } + // returns stats with the fields' default values respective of their type if c.state.State != define.ContainerStateRunning && c.state.State != define.ContainerStatePaused { - return stats, define.ErrCtrStateInvalid + return stats, nil } if previousStats == nil { |