From 6ad13d126b7d79d6e2a0c0600d972c1e3b1f37a7 Mon Sep 17 00:00:00 2001 From: Victor Marmol Date: Thu, 18 Dec 2014 16:09:50 -0800 Subject: [PATCH] Check filesystem before accessing it in UI. Fixes #377. --- container/raw/handler.go | 6 ++++-- pages/static/containers_js.go | 9 ++++++--- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/container/raw/handler.go b/container/raw/handler.go index a49bd51e07..650049c545 100644 --- a/container/raw/handler.go +++ b/container/raw/handler.go @@ -201,7 +201,6 @@ func (self *rawContainerHandler) GetSpec() (info.ContainerSpec, error) { } func (self *rawContainerHandler) getFsStats(stats *info.ContainerStats) error { - // Get Filesystem information only for the root cgroup. if self.name == "/" { filesystems, err := self.fsInfo.GetGlobalFsInfo() @@ -210,7 +209,10 @@ func (self *rawContainerHandler) getFsStats(stats *info.ContainerStats) error { } for _, fs := range filesystems { stats.Filesystem = append(stats.Filesystem, - info.FsStats{fs.Device, fs.Capacity, fs.Capacity - fs.Free, + info.FsStats{ + fs.Device, + fs.Capacity, + fs.Capacity - fs.Free, fs.DiskStats.ReadsCompleted, fs.DiskStats.ReadsMerged, fs.DiskStats.SectorsRead, diff --git a/pages/static/containers_js.go b/pages/static/containers_js.go index 9ffc512d87..1c36e48710 100644 --- a/pages/static/containers_js.go +++ b/pages/static/containers_js.go @@ -1750,10 +1750,13 @@ function startFileSystemUsage(elementId, machineInfo, stats) { // A map of device name to DOM elements. window.cadvisor.fsUsage.elements = {}; - var curr = stats.stats[stats.stats.length - 1]; + var cur = stats.stats[stats.stats.length - 1]; var el = $("
"); - for (var i = 0; i < curr.filesystem.length; i++) { - var data = curr.filesystem[i]; + if (!cur.filesystem) { + return; + } + for (var i = 0; i < cur.filesystem.length; i++) { + var data = cur.filesystem[i]; el.append($("
") .addClass("row col-sm-12") .append($("

")