Skip to content

Commit 4b788c6

Browse files
thaJeztahdims
authored andcommitted
container/docker: GetStats: prevent nil-pointer
stats can be nil if an error occurs during collecting Signed-off-by: Sebastiaan van Stijn <[email protected]>
1 parent 9ad7b85 commit 4b788c6

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

container/docker/handler.go

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -325,15 +325,13 @@ func (h *dockerContainerHandler) GetSpec() (info.ContainerSpec, error) {
325325
return spec, err
326326
}
327327

328-
// TODO(vmarmol): Get from libcontainer API instead of cgroup manager when we don't have to support older Dockers.
329328
func (h *dockerContainerHandler) GetStats() (*info.ContainerStats, error) {
329+
// TODO(vmarmol): Get from libcontainer API instead of cgroup manager when we don't have to support older Dockers.
330330
stats, err := h.libcontainerHandler.GetStats()
331-
332-
stats.Health.Status = h.healthStatus
333-
334331
if err != nil {
335332
return stats, err
336333
}
334+
stats.Health.Status = h.healthStatus
337335

338336
// Get filesystem stats.
339337
err = FsStats(stats, h.machineInfoFactory, h.includedMetrics, h.storageDriver,

0 commit comments

Comments
 (0)