From 2a81a149da040e22dcd253c65dfb09e3c1124e4c Mon Sep 17 00:00:00 2001 From: Vishnu Kannan Date: Wed, 23 Jul 2014 21:18:58 +0000 Subject: [PATCH] Make NetworkStats a pointer to help the callers ignore that stats if it cannot be returned for any reason. Docker-DCO-1.1-Signed-off-by: Vishnu Kannan (github: vishh) --- network/stats.go | 8 ++++---- types.go | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/network/stats.go b/network/stats.go index b69fa9185..231e0646a 100644 --- a/network/stats.go +++ b/network/stats.go @@ -20,17 +20,17 @@ type NetworkStats struct { } // Returns the network statistics for the network interfaces represented by the NetworkRuntimeInfo. -func GetStats(networkState *NetworkState) (NetworkStats, error) { +func GetStats(networkState *NetworkState) (*NetworkStats, error) { // This can happen if the network runtime information is missing - possible if the container was created by an old version of libcontainer. if networkState.VethHost == "" { - return NetworkStats{}, nil + return nil, nil } data, err := readSysfsNetworkStats(networkState.VethHost) if err != nil { - return NetworkStats{}, err + return nil, err } - return NetworkStats{ + return &NetworkStats{ RxBytes: data["rx_bytes"], RxPackets: data["rx_packets"], RxErrors: data["rx_errors"], diff --git a/types.go b/types.go index 5095dca66..a430d826f 100644 --- a/types.go +++ b/types.go @@ -6,6 +6,6 @@ import ( ) type ContainerStats struct { - NetworkStats network.NetworkStats `json:"network_stats, omitempty"` - CgroupStats *cgroups.Stats `json:"cgroup_stats, omitempty"` + NetworkStats *network.NetworkStats `json:"network_stats, omitempty"` + CgroupStats *cgroups.Stats `json:"cgroup_stats, omitempty"` }