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()
}

View File

@@ -12,9 +12,9 @@ go_library(
visibility = ["//visibility:public"],
deps = [
"//vendor/github.com/blang/semver:go_default_library",
"//vendor/github.com/docker/engine-api/client:go_default_library",
"//vendor/github.com/docker/engine-api/types:go_default_library",
"//vendor/github.com/docker/engine-api/types/container:go_default_library",
"//vendor/github.com/docker/docker/api/types:go_default_library",
"//vendor/github.com/docker/docker/api/types/container:go_default_library",
"//vendor/github.com/docker/docker/client:go_default_library",
"//vendor/github.com/docker/go-connections/tlsconfig:go_default_library",
"//vendor/github.com/golang/glog:go_default_library",
"//vendor/github.com/google/cadvisor/container:go_default_library",

View File

@@ -21,7 +21,7 @@ import (
"net/http"
"sync"
dclient "github.com/docker/engine-api/client"
dclient "github.com/docker/docker/client"
"github.com/docker/go-connections/tlsconfig"
)

View File

@@ -19,9 +19,8 @@ import (
"fmt"
"regexp"
"strconv"
"strings"
dockertypes "github.com/docker/engine-api/types"
dockertypes "github.com/docker/docker/api/types"
"golang.org/x/net/context"
"github.com/google/cadvisor/info/v1"
@@ -49,7 +48,6 @@ func StatusFromDockerInfo(dockerInfo dockertypes.Info) v1.DockerStatus {
out.Hostname = dockerInfo.Name
out.RootDir = dockerInfo.DockerRootDir
out.Driver = dockerInfo.Driver
out.ExecDriver = dockerInfo.ExecutionDriver
out.NumImages = dockerInfo.Images
out.NumContainers = dockerInfo.Containers
out.DriverStatus = make(map[string]string, len(dockerInfo.DriverStatus))
@@ -119,13 +117,6 @@ func ValidateInfo() (*dockertypes.Info, error) {
return nil, fmt.Errorf("cAdvisor requires docker version %v or above but we have found version %v reported as %q", []int{1, 0, 0}, version, dockerInfo.ServerVersion)
}
// Check that the libcontainer execdriver is used if the version is < 1.11
// (execution drivers are no longer supported as of 1.11).
if version[0] <= 1 && version[1] <= 10 &&
!strings.HasPrefix(dockerInfo.ExecutionDriver, "native") {
return nil, fmt.Errorf("docker found, but not using native exec driver")
}
if dockerInfo.Driver == "" {
return nil, fmt.Errorf("failed to find docker storage driver")
}

View File

@@ -24,7 +24,7 @@ import (
"sync"
"github.com/blang/semver"
dockertypes "github.com/docker/engine-api/types"
dockertypes "github.com/docker/docker/api/types"
"github.com/google/cadvisor/container"
"github.com/google/cadvisor/container/libcontainer"
"github.com/google/cadvisor/devicemapper"
@@ -35,7 +35,7 @@ import (
dockerutil "github.com/google/cadvisor/utils/docker"
"github.com/google/cadvisor/zfs"
docker "github.com/docker/engine-api/client"
docker "github.com/docker/docker/client"
"github.com/golang/glog"
"golang.org/x/net/context"
)

View File

@@ -32,8 +32,8 @@ import (
dockerutil "github.com/google/cadvisor/utils/docker"
"github.com/google/cadvisor/zfs"
docker "github.com/docker/engine-api/client"
dockercontainer "github.com/docker/engine-api/types/container"
dockercontainer "github.com/docker/docker/api/types/container"
docker "github.com/docker/docker/client"
"github.com/golang/glog"
"github.com/opencontainers/runc/libcontainer/cgroups"
cgroupfs "github.com/opencontainers/runc/libcontainer/cgroups/fs"

View File

@@ -84,6 +84,7 @@ var supportedSubsystems map[string]struct{} = map[string]struct{}{
"memory": {},
"cpuset": {},
"blkio": {},
"devices": {},
}
// Get cgroup and networking stats of the specified container
@@ -452,6 +453,17 @@ var numCpusFunc = getNumberOnlineCPUs
func setCpuStats(s *cgroups.Stats, ret *info.ContainerStats) {
ret.Cpu.Usage.User = s.CpuStats.CpuUsage.UsageInUsermode
ret.Cpu.Usage.System = s.CpuStats.CpuUsage.UsageInKernelmode
ret.Cpu.Usage.Total = 0
ret.Cpu.CFS.Periods = s.CpuStats.ThrottlingData.Periods
ret.Cpu.CFS.ThrottledPeriods = s.CpuStats.ThrottlingData.ThrottledPeriods
ret.Cpu.CFS.ThrottledTime = s.CpuStats.ThrottlingData.ThrottledTime
if len(s.CpuStats.CpuUsage.PercpuUsage) == 0 {
// libcontainer's 'GetStats' can leave 'PercpuUsage' nil if it skipped the
// cpuacct subsystem.
return
}
numPossible := uint32(len(s.CpuStats.CpuUsage.PercpuUsage))
// Note that as of https://patchwork.kernel.org/patch/8607101/ (kernel v4.7),
// the percpu usage information includes extra zero values for all additional
@@ -470,15 +482,11 @@ func setCpuStats(s *cgroups.Stats, ret *info.ContainerStats) {
numActual = minUint32(numPossible, numActual)
ret.Cpu.Usage.PerCpu = make([]uint64, numActual)
ret.Cpu.Usage.Total = 0
for i := uint32(0); i < numActual; i++ {
ret.Cpu.Usage.PerCpu[i] = s.CpuStats.CpuUsage.PercpuUsage[i]
ret.Cpu.Usage.Total += s.CpuStats.CpuUsage.PercpuUsage[i]
}
ret.Cpu.CFS.Periods = s.CpuStats.ThrottlingData.Periods
ret.Cpu.CFS.ThrottledPeriods = s.CpuStats.ThrottlingData.ThrottledPeriods
ret.Cpu.CFS.ThrottledTime = s.CpuStats.ThrottlingData.ThrottledTime
}
// Copied from
@@ -509,6 +517,7 @@ func setDiskIoStats(s *cgroups.Stats, ret *info.ContainerStats) {
func setMemoryStats(s *cgroups.Stats, ret *info.ContainerStats) {
ret.Memory.Usage = s.MemoryStats.Usage.Usage
ret.Memory.MaxUsage = s.MemoryStats.Usage.MaxUsage
ret.Memory.Failcnt = s.MemoryStats.Usage.Failcnt
ret.Memory.Cache = s.MemoryStats.Stats["cache"]