Skip to content

Commit

Permalink
Check filesystem before accessing it in UI.
Browse files Browse the repository at this point in the history
Fixes #377.
  • Loading branch information
vmarmol committed Dec 19, 2014
1 parent 37db214 commit 6ad13d1
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
6 changes: 4 additions & 2 deletions container/raw/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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,
Expand Down
9 changes: 6 additions & 3 deletions pages/static/containers_js.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 = $("<div>");
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($("<div>")
.addClass("row col-sm-12")
.append($("<h4>")
Expand Down

0 comments on commit 6ad13d1

Please sign in to comment.