Fix nil dereference

This commit is contained in:
Alex Dadgar
2017-01-10 14:14:58 -08:00
parent 3da811cc27
commit 47d48bdaee
2 changed files with 7 additions and 2 deletions

View File

@@ -184,8 +184,13 @@ func (a *AllocGarbageCollector) keepUsageBelowThreshold() error {
}
// See if we are below thresholds for used disk space and inode usage
diskStats := a.statsCollector.Stats().AllocDirStats
// TODO(diptanu) figure out why this is nil
stats := a.statsCollector.Stats()
if stats == nil {
break
}
diskStats := stats.AllocDirStats
if diskStats == nil {
break
}

View File

@@ -156,8 +156,8 @@ func (h *HostStatsCollector) Collect() error {
hs.Uptime = uptime
h.hostStatsLock.Lock()
defer h.hostStatsLock.Unlock()
h.hostStats = hs
h.hostStatsLock.Unlock()
return nil
}