summaryrefslogtreecommitdiff
path: root/libpod/stats.go
diff options
context:
space:
mode:
authorhaircommander <pehunt@redhat.com>2018-08-20 18:24:35 -0400
committerAtomic Bot <atomic-devel@projectatomic.io>2018-08-21 15:37:39 +0000
commit149481a57184becf3e9be329d253602654414118 (patch)
treedff153e67e834673756e2f10aed2c6bfb7494067 /libpod/stats.go
parent021027a24b7b6906a2d7ed86c67e34167bc26284 (diff)
downloadpodman-149481a57184becf3e9be329d253602654414118.tar.gz
podman-149481a57184becf3e9be329d253602654414118.tar.bz2
podman-149481a57184becf3e9be329d253602654414118.zip
Fixed segfault in stats where container had netNS none or from container
Signed-off-by: haircommander <pehunt@redhat.com> Closes: #1306 Approved by: rhatdan
Diffstat (limited to 'libpod/stats.go')
-rw-r--r--libpod/stats.go10
1 files changed, 8 insertions, 2 deletions
diff --git a/libpod/stats.go b/libpod/stats.go
index 7830919ba..61e85ed5e 100644
--- a/libpod/stats.go
+++ b/libpod/stats.go
@@ -66,8 +66,14 @@ func (c *Container) GetContainerStats(previousStats *ContainerStats) (*Container
stats.BlockInput, stats.BlockOutput = calculateBlockIO(cgroupStats)
stats.CPUNano = cgroupStats.CPU.Usage.Total
stats.SystemNano = cgroupStats.CPU.Usage.Kernel
- stats.NetInput = netStats.TxBytes
- stats.NetOutput = netStats.RxBytes
+ // Handle case where the container is not in a network namespace
+ if netStats != nil {
+ stats.NetInput = netStats.TxBytes
+ stats.NetOutput = netStats.RxBytes
+ } else {
+ stats.NetInput = 0
+ stats.NetOutput = 0
+ }
return stats, nil
}