Skip to content

Commit

Permalink
stats: map MaxUsage to the correct value
Browse files Browse the repository at this point in the history
and make sure it is not set for cgroup v2

Signed-off-by: Giuseppe Scrivano <[email protected]>
  • Loading branch information
giuseppe committed Sep 14, 2022
1 parent a73b150 commit cf2118e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion pkg/api/handlers/compat/containers_stats.go
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ streamLabel: // A label to flatten the scope
PreCPUStats: preCPUStats,
MemoryStats: docker.MemoryStats{
Usage: cgroupStat.MemoryStats.Usage.Usage,
MaxUsage: cgroupStat.MemoryStats.Usage.Limit,
MaxUsage: cgroupStat.MemoryStats.Usage.MaxUsage,
Stats: nil,
Failcnt: 0,
Limit: memoryLimit,
Expand Down
6 changes: 6 additions & 0 deletions test/apiv2/20-containers.at
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,12 @@ else
fi
fi

# max_usage is not set for cgroupv2
if have_cgroupsv2; then
t GET libpod/containers/stats?containers='[$cid]' 200 \
.memory_stats.max_usage=null
fi

t DELETE libpod/containers/$cid 200 .[0].Id=$cid

# Issue #14676: make sure the stats show the memory limit specified for the container
Expand Down

0 comments on commit cf2118e

Please sign in to comment.