Update cAdvisor.

Also update golang.org/x/sys because of google/cadvisor#1786
This commit is contained in:
Rohit Agarwal
2017-11-06 13:54:48 -08:00
parent dad41f8526
commit fe5ef1b494
297 changed files with 10024 additions and 8974 deletions

View File

@@ -11,12 +11,12 @@ go_library(
importpath = "github.com/google/cadvisor/container/common",
visibility = ["//visibility:public"],
deps = [
"//vendor/github.com/fsnotify/fsnotify:go_default_library",
"//vendor/github.com/golang/glog:go_default_library",
"//vendor/github.com/google/cadvisor/container:go_default_library",
"//vendor/github.com/google/cadvisor/fs:go_default_library",
"//vendor/github.com/google/cadvisor/info/v1:go_default_library",
"//vendor/github.com/google/cadvisor/utils:go_default_library",
"//vendor/golang.org/x/exp/inotify:go_default_library",
],
)

View File

@@ -51,7 +51,6 @@ type realFsHandler struct {
}
const (
longOp = time.Second
timeout = 2 * time.Minute
maxBackoffFactor = 20
)
@@ -93,10 +92,10 @@ func (fh *realFsHandler) update() error {
fh.Lock()
defer fh.Unlock()
fh.lastUpdate = time.Now()
if rootDiskErr == nil && fh.rootfs != "" {
if rootInodeErr == nil && fh.rootfs != "" {
fh.usage.InodeUsage = inodeUsage
}
if rootInodeErr == nil && fh.rootfs != "" {
if rootDiskErr == nil && fh.rootfs != "" {
fh.usage.TotalUsageBytes = baseUsage + extraDirUsage
}
if extraDiskErr == nil && fh.extraDir != "" {
@@ -111,6 +110,7 @@ func (fh *realFsHandler) update() error {
func (fh *realFsHandler) trackUsage() {
fh.update()
longOp := time.Second
for {
select {
case <-fh.stopChan:
@@ -128,7 +128,11 @@ func (fh *realFsHandler) trackUsage() {
}
duration := time.Since(start)
if duration > longOp {
glog.V(2).Infof("du and find on following dirs took %v: %v", duration, []string{fh.rootfs, fh.extraDir})
// adapt longOp time so that message doesn't continue to print
// if the long duration is persistent either because of slow
// disk or lots of containers.
longOp = longOp + time.Second
glog.V(2).Infof("du and find on following dirs took %v: %v; will not log again for this container unless duration exceeds %v", duration, []string{fh.rootfs, fh.extraDir}, longOp)
}
}
}

View File

@@ -17,15 +17,15 @@ package common
import (
"sync"
"golang.org/x/exp/inotify"
"github.com/fsnotify/fsnotify"
)
// Watcher for container-related inotify events in the cgroup hierarchy.
// Watcher for container-related fsnotify events in the cgroup hierarchy.
//
// Implementation is thread-safe.
type InotifyWatcher struct {
// Underlying inotify watcher.
watcher *inotify.Watcher
// Underlying fsnotify watcher.
watcher *fsnotify.Watcher
// Map of containers being watched to cgroup paths watched for that container.
containersWatched map[string]map[string]bool
@@ -35,7 +35,7 @@ type InotifyWatcher struct {
}
func NewInotifyWatcher() (*InotifyWatcher, error) {
w, err := inotify.NewWatcher()
w, err := fsnotify.NewWatcher()
if err != nil {
return nil, err
}
@@ -53,9 +53,9 @@ func (iw *InotifyWatcher) AddWatch(containerName, dir string) (bool, error) {
cgroupsWatched, alreadyWatched := iw.containersWatched[containerName]
// Register an inotify notification.
// Register an fsnotify notification.
if !cgroupsWatched[dir] {
err := iw.watcher.AddWatch(dir, inotify.IN_CREATE|inotify.IN_DELETE|inotify.IN_MOVE)
err := iw.watcher.Add(dir)
if err != nil {
return alreadyWatched, err
}
@@ -84,9 +84,9 @@ func (iw *InotifyWatcher) RemoveWatch(containerName, dir string) (bool, error) {
return false, nil
}
// Remove the inotify watch if it exists.
// Remove the fsnotify watch if it exists.
if cgroupsWatched[dir] {
err := iw.watcher.RemoveWatch(dir)
err := iw.watcher.Remove(dir)
if err != nil {
return false, nil
}
@@ -104,15 +104,15 @@ func (iw *InotifyWatcher) RemoveWatch(containerName, dir string) (bool, error) {
// Errors are returned on this channel.
func (iw *InotifyWatcher) Error() chan error {
return iw.watcher.Error
return iw.watcher.Errors
}
// Events are returned on this channel.
func (iw *InotifyWatcher) Event() chan *inotify.Event {
return iw.watcher.Event
func (iw *InotifyWatcher) Event() chan fsnotify.Event {
return iw.watcher.Events
}
// Closes the inotify watcher.
// Closes the fsnotify watcher.
func (iw *InotifyWatcher) Close() error {
return iw.watcher.Close()
}