diff options
author | OpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com> | 2022-03-23 20:37:25 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-03-23 20:37:25 +0100 |
commit | 73713062806aa4c2db25dc62e2fff47406085dc8 (patch) | |
tree | 218b63ae146c34a784e238c43c18a33eca971d85 /pkg | |
parent | 109224717354b1d32d1be854a019fe9d4a55cfa6 (diff) | |
parent | 130bcc3a93d82674eaaf2a62f854983db263a940 (diff) | |
download | podman-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 'pkg')
-rw-r--r-- | pkg/api/handlers/compat/containers_stats.go | 2 | ||||
-rw-r--r-- | pkg/domain/infra/abi/containers.go | 7 |
2 files changed, 2 insertions, 7 deletions
diff --git a/pkg/api/handlers/compat/containers_stats.go b/pkg/api/handlers/compat/containers_stats.go index 99f14d02f..77b16b03e 100644 --- a/pkg/api/handlers/compat/containers_stats.go +++ b/pkg/api/handlers/compat/containers_stats.go @@ -56,7 +56,7 @@ func StatsContainer(w http.ResponseWriter, r *http.Request) { return } - stats, err := ctnr.GetContainerStats(&define.ContainerStats{}) + stats, err := ctnr.GetContainerStats(nil) if err != nil { utils.InternalServerError(w, errors.Wrapf(err, "failed to obtain Container %s stats", name)) return diff --git a/pkg/domain/infra/abi/containers.go b/pkg/domain/infra/abi/containers.go index e6feb7c82..1986228a6 100644 --- a/pkg/domain/infra/abi/containers.go +++ b/pkg/domain/infra/abi/containers.go @@ -1431,12 +1431,7 @@ func (ic *ContainerEngine) ContainerStats(ctx context.Context, namesOrIds []stri reportStats := []define.ContainerStats{} for _, ctr := range containers { - prev, ok := containerStats[ctr.ID()] - if !ok { - prev = &define.ContainerStats{} - } - - stats, err := ctr.GetContainerStats(prev) + stats, err := ctr.GetContainerStats(containerStats[ctr.ID()]) if err != nil { cause := errors.Cause(err) if queryAll && (cause == define.ErrCtrRemoved || cause == define.ErrNoSuchCtr || cause == define.ErrCtrStateInvalid) { |