From c3df9dd73f8074cf3cffb2121a0ecec74880d099 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christoffer=20Kylv=C3=A5g?= Date: Tue, 13 Dec 2016 12:28:57 +0100 Subject: [PATCH] #1680: Continue after not being able to stat a mountpoint --- client/client.go | 2 +- client/stats/host.go | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/client/client.go b/client/client.go index e975ea8b88e..748a84c6a84 100644 --- a/client/client.go +++ b/client/client.go @@ -182,7 +182,7 @@ func NewClient(cfg *config.Config, consulSyncer *consul.Syncer, logger *log.Logg start: time.Now(), connPool: nomad.NewPool(cfg.LogOutput, clientRPCCache, clientMaxStreams, tlsWrap), logger: logger, - hostStatsCollector: stats.NewHostStatsCollector(), + hostStatsCollector: stats.NewHostStatsCollector(logger), allocs: make(map[string]*AllocRunner), blockedAllocations: make(map[string]*structs.Allocation), allocUpdates: make(chan *structs.Allocation, 64), diff --git a/client/stats/host.go b/client/stats/host.go index bf4a6b1494e..49fb0fdcb74 100644 --- a/client/stats/host.go +++ b/client/stats/host.go @@ -1,6 +1,7 @@ package stats import ( + "log" "math" "runtime" "time" @@ -56,15 +57,17 @@ type HostStatsCollector struct { clkSpeed float64 numCores int statsCalculator map[string]*HostCpuStatsCalculator + logger *log.Logger } // NewHostStatsCollector returns a HostStatsCollector -func NewHostStatsCollector() *HostStatsCollector { +func NewHostStatsCollector(logger *log.Logger) *HostStatsCollector { numCores := runtime.NumCPU() statsCalculator := make(map[string]*HostCpuStatsCalculator) collector := &HostStatsCollector{ statsCalculator: statsCalculator, numCores: numCores, + logger: logger, } return collector } @@ -116,7 +119,8 @@ func (h *HostStatsCollector) Collect() (*HostStats, error) { for _, partition := range partitions { usage, err := disk.Usage(partition.Mountpoint) if err != nil { - return nil, err + h.logger.Printf("[WARN] client: error fetching host disk usage stats for %v: %v", partition.Mountpoint, err) + continue } ds := DiskStats{ Device: partition.Device,