summaryrefslogtreecommitdiff
path: root/libpod/pod.go
diff options
context:
space:
mode:
authorOpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com>2022-03-23 20:37:25 +0100
committerGitHub <noreply@github.com>2022-03-23 20:37:25 +0100
commit73713062806aa4c2db25dc62e2fff47406085dc8 (patch)
tree218b63ae146c34a784e238c43c18a33eca971d85 /libpod/pod.go
parent109224717354b1d32d1be854a019fe9d4a55cfa6 (diff)
parent130bcc3a93d82674eaaf2a62f854983db263a940 (diff)
downloadpodman-73713062806aa4c2db25dc62e2fff47406085dc8.tar.gz
podman-73713062806aa4c2db25dc62e2fff47406085dc8.tar.bz2
podman-73713062806aa4c2db25dc62e2fff47406085dc8.zip
Merge pull request #13597 from Luap99/stats
podman stats: calc CPU percentage correctly
Diffstat (limited to 'libpod/pod.go')
-rw-r--r--libpod/pod.go9
1 files changed, 1 insertions, 8 deletions
diff --git a/libpod/pod.go b/libpod/pod.go
index 6273ff247..ed2d97b37 100644
--- a/libpod/pod.go
+++ b/libpod/pod.go
@@ -422,10 +422,6 @@ type PodContainerStats struct {
// GetPodStats returns the stats for each of its containers
func (p *Pod) GetPodStats(previousContainerStats map[string]*define.ContainerStats) (map[string]*define.ContainerStats, error) {
- var (
- ok bool
- prevStat *define.ContainerStats
- )
p.lock.Lock()
defer p.lock.Unlock()
@@ -438,10 +434,7 @@ func (p *Pod) GetPodStats(previousContainerStats map[string]*define.ContainerSta
}
newContainerStats := make(map[string]*define.ContainerStats)
for _, c := range containers {
- if prevStat, ok = previousContainerStats[c.ID()]; !ok {
- prevStat = &define.ContainerStats{}
- }
- newStats, err := c.GetContainerStats(prevStat)
+ newStats, err := c.GetContainerStats(previousContainerStats[c.ID()])
// If the container wasn't running, don't include it
// but also suppress the error
if err != nil && errors.Cause(err) != define.ErrCtrStateInvalid {