Check filesystem before accessing it in UI.

Fixes #377.
This commit is contained in:
Victor Marmol 2014-12-18 16:09:50 -08:00
parent 37db214c71
commit 6ad13d126b
2 changed files with 10 additions and 5 deletions

View File

@ -201,7 +201,6 @@ func (self *rawContainerHandler) GetSpec() (info.ContainerSpec, error) {
} }
func (self *rawContainerHandler) getFsStats(stats *info.ContainerStats) error { func (self *rawContainerHandler) getFsStats(stats *info.ContainerStats) error {
// Get Filesystem information only for the root cgroup. // Get Filesystem information only for the root cgroup.
if self.name == "/" { if self.name == "/" {
filesystems, err := self.fsInfo.GetGlobalFsInfo() filesystems, err := self.fsInfo.GetGlobalFsInfo()
@ -210,7 +209,10 @@ func (self *rawContainerHandler) getFsStats(stats *info.ContainerStats) error {
} }
for _, fs := range filesystems { for _, fs := range filesystems {
stats.Filesystem = append(stats.Filesystem, 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.ReadsCompleted,
fs.DiskStats.ReadsMerged, fs.DiskStats.ReadsMerged,
fs.DiskStats.SectorsRead, fs.DiskStats.SectorsRead,

View File

@ -1750,10 +1750,13 @@ function startFileSystemUsage(elementId, machineInfo, stats) {
// A map of device name to DOM elements. // A map of device name to DOM elements.
window.cadvisor.fsUsage.elements = {}; window.cadvisor.fsUsage.elements = {};
var curr = stats.stats[stats.stats.length - 1]; var cur = stats.stats[stats.stats.length - 1];
var el = $("<div>"); var el = $("<div>");
for (var i = 0; i < curr.filesystem.length; i++) { if (!cur.filesystem) {
var data = curr.filesystem[i]; return;
}
for (var i = 0; i < cur.filesystem.length; i++) {
var data = cur.filesystem[i];
el.append($("<div>") el.append($("<div>")
.addClass("row col-sm-12") .addClass("row col-sm-12")
.append($("<h4>") .append($("<h4>")