mirror of
https://github.com/podman-container-tools/podman.git
synced 2026-08-27 18:57:53 +00:00
Merge pull request #29628 from mehrdadbn9/fix/29627-stats-nil-pointer
fix(api): nil check Memory.Limit before dereference in stats handler
This commit is contained in:
commit
ca42cbff0a
2 changed files with 7 additions and 1 deletions
|
|
@ -72,7 +72,7 @@ func statsContainerJSON(ctnr *libpod.Container, stats *define.ContainerStats, pr
|
|||
|
||||
resources := ctnr.LinuxResources()
|
||||
memoryLimit := cgroupStat.MemoryStats.Usage.Limit
|
||||
if resources != nil && resources.Memory != nil && *resources.Memory.Limit > 0 {
|
||||
if resources != nil && resources.Memory != nil && resources.Memory.Limit != nil && *resources.Memory.Limit > 0 {
|
||||
memoryLimit = uint64(*resources.Memory.Limit)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -27,3 +27,9 @@ podman rm -f testctr2
|
|||
|
||||
podman network rm testnet1
|
||||
podman network rm testnet2
|
||||
|
||||
# regression for https://github.com/containers/podman/issues/29627
|
||||
# stats should not panic when memory-reservation is set without memory-limit
|
||||
podman run -dt --name testctr3 --memory-reservation=10m $IMAGE top &>/dev/null
|
||||
t GET libpod/containers/testctr3/stats?stream=false 200
|
||||
podman rm -f testctr3
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue