From 5f8eea99dd3d9128541bd136ee36c65ae73b1256 Mon Sep 17 00:00:00 2001 From: Davanum Srinivas Date: Wed, 27 Dec 2017 12:12:37 -0500 Subject: [PATCH] Skip getVfsStats when file does not exist There are a lot of spurious exceptions in the kubernetes kubelet logs like: E1018 21:03:09.616581 22780 fs.go:332] Stat fs failed. Error: no such file or directory Since we know that calling syscall.Statfs will just fail when the path does not exist, we should just skip making the call. NOTE: fixing 2017->2018 problems in build by running `./build/jenkins_e2e.sh` --- fs/fs.go | 13 +++++++++---- pages/static/assets.go | 2 +- pages/templates.go | 2 +- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/fs/fs.go b/fs/fs.go index 271b01e356..ae11b57680 100644 --- a/fs/fs.go +++ b/fs/fs.go @@ -35,6 +35,7 @@ import ( "github.com/docker/docker/pkg/mount" "github.com/golang/glog" "github.com/google/cadvisor/devicemapper" + "github.com/google/cadvisor/utils" dockerutil "github.com/google/cadvisor/utils/docker" zfs "github.com/mistifyio/go-zfs" ) @@ -409,10 +410,14 @@ func (self *RealFsInfo) GetFsInfoForPath(mountSet map[string]struct{}) ([]Fs, er fs.Type = ZFS default: var inodes, inodesFree uint64 - fs.Capacity, fs.Free, fs.Available, inodes, inodesFree, err = getVfsStats(partition.mountpoint) - fs.Inodes = &inodes - fs.InodesFree = &inodesFree - fs.Type = VFS + if utils.FileExists(partition.mountpoint) { + fs.Capacity, fs.Free, fs.Available, inodes, inodesFree, err = getVfsStats(partition.mountpoint) + fs.Inodes = &inodes + fs.InodesFree = &inodesFree + fs.Type = VFS + } else { + glog.V(4).Infof("unable to determine file system type, partition mountpoint does not exist: %v", partition.mountpoint) + } } if err != nil { glog.Errorf("Stat fs failed. Error: %v", err) diff --git a/pages/static/assets.go b/pages/static/assets.go index 156737f2bd..0e6ad1f3da 100644 --- a/pages/static/assets.go +++ b/pages/static/assets.go @@ -1,4 +1,4 @@ -// Copyright 2017 Google Inc. All Rights Reserved. +// Copyright 2018 Google Inc. All Rights Reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/pages/templates.go b/pages/templates.go index 45f1c18400..b4821d4ae4 100644 --- a/pages/templates.go +++ b/pages/templates.go @@ -1,4 +1,4 @@ -// Copyright 2017 Google Inc. All Rights Reserved. +// Copyright 2018 Google Inc. All Rights Reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License.