Commit 1fa2d3d6 authored by David Ashpole's avatar David Ashpole

update cadvisor godeps to v0.29.2

parent 5208e803
...@@ -1279,6 +1279,7 @@ ...@@ -1279,6 +1279,7 @@
}, },
{ {
"ImportPath": "github.com/evanphx/json-patch", "ImportPath": "github.com/evanphx/json-patch",
"Comment": "v3.0.0-23-g94e38aa",
"Rev": "94e38aa1586e8a6c8a75770bddf5ff84c48a106b" "Rev": "94e38aa1586e8a6c8a75770bddf5ff84c48a106b"
}, },
{ {
...@@ -1542,218 +1543,218 @@ ...@@ -1542,218 +1543,218 @@
}, },
{ {
"ImportPath": "github.com/google/cadvisor/accelerators", "ImportPath": "github.com/google/cadvisor/accelerators",
"Comment": "v0.29.1", "Comment": "v0.29.2",
"Rev": "2e02d28350c5fbbad9cfb7e5a1733468b75ab3f9" "Rev": "74cdd4597b07203ae9e268fc59f96f66f8afdc11"
}, },
{ {
"ImportPath": "github.com/google/cadvisor/api", "ImportPath": "github.com/google/cadvisor/api",
"Comment": "v0.29.1", "Comment": "v0.29.2",
"Rev": "2e02d28350c5fbbad9cfb7e5a1733468b75ab3f9" "Rev": "74cdd4597b07203ae9e268fc59f96f66f8afdc11"
}, },
{ {
"ImportPath": "github.com/google/cadvisor/cache/memory", "ImportPath": "github.com/google/cadvisor/cache/memory",
"Comment": "v0.29.1", "Comment": "v0.29.2",
"Rev": "2e02d28350c5fbbad9cfb7e5a1733468b75ab3f9" "Rev": "74cdd4597b07203ae9e268fc59f96f66f8afdc11"
}, },
{ {
"ImportPath": "github.com/google/cadvisor/client/v2", "ImportPath": "github.com/google/cadvisor/client/v2",
"Comment": "v0.29.1", "Comment": "v0.29.2",
"Rev": "2e02d28350c5fbbad9cfb7e5a1733468b75ab3f9" "Rev": "74cdd4597b07203ae9e268fc59f96f66f8afdc11"
}, },
{ {
"ImportPath": "github.com/google/cadvisor/collector", "ImportPath": "github.com/google/cadvisor/collector",
"Comment": "v0.29.1", "Comment": "v0.29.2",
"Rev": "2e02d28350c5fbbad9cfb7e5a1733468b75ab3f9" "Rev": "74cdd4597b07203ae9e268fc59f96f66f8afdc11"
}, },
{ {
"ImportPath": "github.com/google/cadvisor/container", "ImportPath": "github.com/google/cadvisor/container",
"Comment": "v0.29.1", "Comment": "v0.29.2",
"Rev": "2e02d28350c5fbbad9cfb7e5a1733468b75ab3f9" "Rev": "74cdd4597b07203ae9e268fc59f96f66f8afdc11"
}, },
{ {
"ImportPath": "github.com/google/cadvisor/container/common", "ImportPath": "github.com/google/cadvisor/container/common",
"Comment": "v0.29.1", "Comment": "v0.29.2",
"Rev": "2e02d28350c5fbbad9cfb7e5a1733468b75ab3f9" "Rev": "74cdd4597b07203ae9e268fc59f96f66f8afdc11"
}, },
{ {
"ImportPath": "github.com/google/cadvisor/container/containerd", "ImportPath": "github.com/google/cadvisor/container/containerd",
"Comment": "v0.29.1", "Comment": "v0.29.2",
"Rev": "2e02d28350c5fbbad9cfb7e5a1733468b75ab3f9" "Rev": "74cdd4597b07203ae9e268fc59f96f66f8afdc11"
}, },
{ {
"ImportPath": "github.com/google/cadvisor/container/crio", "ImportPath": "github.com/google/cadvisor/container/crio",
"Comment": "v0.29.1", "Comment": "v0.29.2",
"Rev": "2e02d28350c5fbbad9cfb7e5a1733468b75ab3f9" "Rev": "74cdd4597b07203ae9e268fc59f96f66f8afdc11"
}, },
{ {
"ImportPath": "github.com/google/cadvisor/container/docker", "ImportPath": "github.com/google/cadvisor/container/docker",
"Comment": "v0.29.1", "Comment": "v0.29.2",
"Rev": "2e02d28350c5fbbad9cfb7e5a1733468b75ab3f9" "Rev": "74cdd4597b07203ae9e268fc59f96f66f8afdc11"
}, },
{ {
"ImportPath": "github.com/google/cadvisor/container/libcontainer", "ImportPath": "github.com/google/cadvisor/container/libcontainer",
"Comment": "v0.29.1", "Comment": "v0.29.2",
"Rev": "2e02d28350c5fbbad9cfb7e5a1733468b75ab3f9" "Rev": "74cdd4597b07203ae9e268fc59f96f66f8afdc11"
}, },
{ {
"ImportPath": "github.com/google/cadvisor/container/raw", "ImportPath": "github.com/google/cadvisor/container/raw",
"Comment": "v0.29.1", "Comment": "v0.29.2",
"Rev": "2e02d28350c5fbbad9cfb7e5a1733468b75ab3f9" "Rev": "74cdd4597b07203ae9e268fc59f96f66f8afdc11"
}, },
{ {
"ImportPath": "github.com/google/cadvisor/container/rkt", "ImportPath": "github.com/google/cadvisor/container/rkt",
"Comment": "v0.29.1", "Comment": "v0.29.2",
"Rev": "2e02d28350c5fbbad9cfb7e5a1733468b75ab3f9" "Rev": "74cdd4597b07203ae9e268fc59f96f66f8afdc11"
}, },
{ {
"ImportPath": "github.com/google/cadvisor/container/systemd", "ImportPath": "github.com/google/cadvisor/container/systemd",
"Comment": "v0.29.1", "Comment": "v0.29.2",
"Rev": "2e02d28350c5fbbad9cfb7e5a1733468b75ab3f9" "Rev": "74cdd4597b07203ae9e268fc59f96f66f8afdc11"
}, },
{ {
"ImportPath": "github.com/google/cadvisor/devicemapper", "ImportPath": "github.com/google/cadvisor/devicemapper",
"Comment": "v0.29.1", "Comment": "v0.29.2",
"Rev": "2e02d28350c5fbbad9cfb7e5a1733468b75ab3f9" "Rev": "74cdd4597b07203ae9e268fc59f96f66f8afdc11"
}, },
{ {
"ImportPath": "github.com/google/cadvisor/events", "ImportPath": "github.com/google/cadvisor/events",
"Comment": "v0.29.1", "Comment": "v0.29.2",
"Rev": "2e02d28350c5fbbad9cfb7e5a1733468b75ab3f9" "Rev": "74cdd4597b07203ae9e268fc59f96f66f8afdc11"
}, },
{ {
"ImportPath": "github.com/google/cadvisor/fs", "ImportPath": "github.com/google/cadvisor/fs",
"Comment": "v0.29.1", "Comment": "v0.29.2",
"Rev": "2e02d28350c5fbbad9cfb7e5a1733468b75ab3f9" "Rev": "74cdd4597b07203ae9e268fc59f96f66f8afdc11"
}, },
{ {
"ImportPath": "github.com/google/cadvisor/healthz", "ImportPath": "github.com/google/cadvisor/healthz",
"Comment": "v0.29.1", "Comment": "v0.29.2",
"Rev": "2e02d28350c5fbbad9cfb7e5a1733468b75ab3f9" "Rev": "74cdd4597b07203ae9e268fc59f96f66f8afdc11"
}, },
{ {
"ImportPath": "github.com/google/cadvisor/http", "ImportPath": "github.com/google/cadvisor/http",
"Comment": "v0.29.1", "Comment": "v0.29.2",
"Rev": "2e02d28350c5fbbad9cfb7e5a1733468b75ab3f9" "Rev": "74cdd4597b07203ae9e268fc59f96f66f8afdc11"
}, },
{ {
"ImportPath": "github.com/google/cadvisor/http/mux", "ImportPath": "github.com/google/cadvisor/http/mux",
"Comment": "v0.29.1", "Comment": "v0.29.2",
"Rev": "2e02d28350c5fbbad9cfb7e5a1733468b75ab3f9" "Rev": "74cdd4597b07203ae9e268fc59f96f66f8afdc11"
}, },
{ {
"ImportPath": "github.com/google/cadvisor/info/v1", "ImportPath": "github.com/google/cadvisor/info/v1",
"Comment": "v0.29.1", "Comment": "v0.29.2",
"Rev": "2e02d28350c5fbbad9cfb7e5a1733468b75ab3f9" "Rev": "74cdd4597b07203ae9e268fc59f96f66f8afdc11"
}, },
{ {
"ImportPath": "github.com/google/cadvisor/info/v2", "ImportPath": "github.com/google/cadvisor/info/v2",
"Comment": "v0.29.1", "Comment": "v0.29.2",
"Rev": "2e02d28350c5fbbad9cfb7e5a1733468b75ab3f9" "Rev": "74cdd4597b07203ae9e268fc59f96f66f8afdc11"
}, },
{ {
"ImportPath": "github.com/google/cadvisor/machine", "ImportPath": "github.com/google/cadvisor/machine",
"Comment": "v0.29.1", "Comment": "v0.29.2",
"Rev": "2e02d28350c5fbbad9cfb7e5a1733468b75ab3f9" "Rev": "74cdd4597b07203ae9e268fc59f96f66f8afdc11"
}, },
{ {
"ImportPath": "github.com/google/cadvisor/manager", "ImportPath": "github.com/google/cadvisor/manager",
"Comment": "v0.29.1", "Comment": "v0.29.2",
"Rev": "2e02d28350c5fbbad9cfb7e5a1733468b75ab3f9" "Rev": "74cdd4597b07203ae9e268fc59f96f66f8afdc11"
}, },
{ {
"ImportPath": "github.com/google/cadvisor/manager/watcher", "ImportPath": "github.com/google/cadvisor/manager/watcher",
"Comment": "v0.29.1", "Comment": "v0.29.2",
"Rev": "2e02d28350c5fbbad9cfb7e5a1733468b75ab3f9" "Rev": "74cdd4597b07203ae9e268fc59f96f66f8afdc11"
}, },
{ {
"ImportPath": "github.com/google/cadvisor/manager/watcher/raw", "ImportPath": "github.com/google/cadvisor/manager/watcher/raw",
"Comment": "v0.29.1", "Comment": "v0.29.2",
"Rev": "2e02d28350c5fbbad9cfb7e5a1733468b75ab3f9" "Rev": "74cdd4597b07203ae9e268fc59f96f66f8afdc11"
}, },
{ {
"ImportPath": "github.com/google/cadvisor/manager/watcher/rkt", "ImportPath": "github.com/google/cadvisor/manager/watcher/rkt",
"Comment": "v0.29.1", "Comment": "v0.29.2",
"Rev": "2e02d28350c5fbbad9cfb7e5a1733468b75ab3f9" "Rev": "74cdd4597b07203ae9e268fc59f96f66f8afdc11"
}, },
{ {
"ImportPath": "github.com/google/cadvisor/metrics", "ImportPath": "github.com/google/cadvisor/metrics",
"Comment": "v0.29.1", "Comment": "v0.29.2",
"Rev": "2e02d28350c5fbbad9cfb7e5a1733468b75ab3f9" "Rev": "74cdd4597b07203ae9e268fc59f96f66f8afdc11"
}, },
{ {
"ImportPath": "github.com/google/cadvisor/pages", "ImportPath": "github.com/google/cadvisor/pages",
"Comment": "v0.29.1", "Comment": "v0.29.2",
"Rev": "2e02d28350c5fbbad9cfb7e5a1733468b75ab3f9" "Rev": "74cdd4597b07203ae9e268fc59f96f66f8afdc11"
}, },
{ {
"ImportPath": "github.com/google/cadvisor/pages/static", "ImportPath": "github.com/google/cadvisor/pages/static",
"Comment": "v0.29.1", "Comment": "v0.29.2",
"Rev": "2e02d28350c5fbbad9cfb7e5a1733468b75ab3f9" "Rev": "74cdd4597b07203ae9e268fc59f96f66f8afdc11"
}, },
{ {
"ImportPath": "github.com/google/cadvisor/storage", "ImportPath": "github.com/google/cadvisor/storage",
"Comment": "v0.29.1", "Comment": "v0.29.2",
"Rev": "2e02d28350c5fbbad9cfb7e5a1733468b75ab3f9" "Rev": "74cdd4597b07203ae9e268fc59f96f66f8afdc11"
}, },
{ {
"ImportPath": "github.com/google/cadvisor/summary", "ImportPath": "github.com/google/cadvisor/summary",
"Comment": "v0.29.1", "Comment": "v0.29.2",
"Rev": "2e02d28350c5fbbad9cfb7e5a1733468b75ab3f9" "Rev": "74cdd4597b07203ae9e268fc59f96f66f8afdc11"
}, },
{ {
"ImportPath": "github.com/google/cadvisor/utils", "ImportPath": "github.com/google/cadvisor/utils",
"Comment": "v0.29.1", "Comment": "v0.29.2",
"Rev": "2e02d28350c5fbbad9cfb7e5a1733468b75ab3f9" "Rev": "74cdd4597b07203ae9e268fc59f96f66f8afdc11"
}, },
{ {
"ImportPath": "github.com/google/cadvisor/utils/cloudinfo", "ImportPath": "github.com/google/cadvisor/utils/cloudinfo",
"Comment": "v0.29.1", "Comment": "v0.29.2",
"Rev": "2e02d28350c5fbbad9cfb7e5a1733468b75ab3f9" "Rev": "74cdd4597b07203ae9e268fc59f96f66f8afdc11"
}, },
{ {
"ImportPath": "github.com/google/cadvisor/utils/cpuload", "ImportPath": "github.com/google/cadvisor/utils/cpuload",
"Comment": "v0.29.1", "Comment": "v0.29.2",
"Rev": "2e02d28350c5fbbad9cfb7e5a1733468b75ab3f9" "Rev": "74cdd4597b07203ae9e268fc59f96f66f8afdc11"
}, },
{ {
"ImportPath": "github.com/google/cadvisor/utils/cpuload/netlink", "ImportPath": "github.com/google/cadvisor/utils/cpuload/netlink",
"Comment": "v0.29.1", "Comment": "v0.29.2",
"Rev": "2e02d28350c5fbbad9cfb7e5a1733468b75ab3f9" "Rev": "74cdd4597b07203ae9e268fc59f96f66f8afdc11"
}, },
{ {
"ImportPath": "github.com/google/cadvisor/utils/docker", "ImportPath": "github.com/google/cadvisor/utils/docker",
"Comment": "v0.29.1", "Comment": "v0.29.2",
"Rev": "2e02d28350c5fbbad9cfb7e5a1733468b75ab3f9" "Rev": "74cdd4597b07203ae9e268fc59f96f66f8afdc11"
}, },
{ {
"ImportPath": "github.com/google/cadvisor/utils/oomparser", "ImportPath": "github.com/google/cadvisor/utils/oomparser",
"Comment": "v0.29.1", "Comment": "v0.29.2",
"Rev": "2e02d28350c5fbbad9cfb7e5a1733468b75ab3f9" "Rev": "74cdd4597b07203ae9e268fc59f96f66f8afdc11"
}, },
{ {
"ImportPath": "github.com/google/cadvisor/utils/sysfs", "ImportPath": "github.com/google/cadvisor/utils/sysfs",
"Comment": "v0.29.1", "Comment": "v0.29.2",
"Rev": "2e02d28350c5fbbad9cfb7e5a1733468b75ab3f9" "Rev": "74cdd4597b07203ae9e268fc59f96f66f8afdc11"
}, },
{ {
"ImportPath": "github.com/google/cadvisor/utils/sysinfo", "ImportPath": "github.com/google/cadvisor/utils/sysinfo",
"Comment": "v0.29.1", "Comment": "v0.29.2",
"Rev": "2e02d28350c5fbbad9cfb7e5a1733468b75ab3f9" "Rev": "74cdd4597b07203ae9e268fc59f96f66f8afdc11"
}, },
{ {
"ImportPath": "github.com/google/cadvisor/validate", "ImportPath": "github.com/google/cadvisor/validate",
"Comment": "v0.29.1", "Comment": "v0.29.2",
"Rev": "2e02d28350c5fbbad9cfb7e5a1733468b75ab3f9" "Rev": "74cdd4597b07203ae9e268fc59f96f66f8afdc11"
}, },
{ {
"ImportPath": "github.com/google/cadvisor/version", "ImportPath": "github.com/google/cadvisor/version",
"Comment": "v0.29.1", "Comment": "v0.29.2",
"Rev": "2e02d28350c5fbbad9cfb7e5a1733468b75ab3f9" "Rev": "74cdd4597b07203ae9e268fc59f96f66f8afdc11"
}, },
{ {
"ImportPath": "github.com/google/cadvisor/zfs", "ImportPath": "github.com/google/cadvisor/zfs",
"Comment": "v0.29.1", "Comment": "v0.29.2",
"Rev": "2e02d28350c5fbbad9cfb7e5a1733468b75ab3f9" "Rev": "74cdd4597b07203ae9e268fc59f96f66f8afdc11"
}, },
{ {
"ImportPath": "github.com/google/certificate-transparency/go", "ImportPath": "github.com/google/certificate-transparency/go",
...@@ -2191,10 +2192,12 @@ ...@@ -2191,10 +2192,12 @@
}, },
{ {
"ImportPath": "github.com/modern-go/concurrent", "ImportPath": "github.com/modern-go/concurrent",
"Comment": "1.0.3",
"Rev": "bacd9c7ef1dd9b15be4a9909b8ac7a4e313eec94" "Rev": "bacd9c7ef1dd9b15be4a9909b8ac7a4e313eec94"
}, },
{ {
"ImportPath": "github.com/modern-go/reflect2", "ImportPath": "github.com/modern-go/reflect2",
"Comment": "1.0.0-9-g05fbef0",
"Rev": "05fbef0ca5da472bbf96c9322b84a53edc03c9fd" "Rev": "05fbef0ca5da472bbf96c9322b84a53edc03c9fd"
}, },
{ {
......
...@@ -31,7 +31,10 @@ import ( ...@@ -31,7 +31,10 @@ import (
) )
type NvidiaManager struct { type NvidiaManager struct {
sync.RWMutex sync.Mutex
// true if there are NVIDIA devices present on the node
devicesPresent bool
// true if the NVML library (libnvidia-ml.so.1) was loaded successfully // true if the NVML library (libnvidia-ml.so.1) was loaded successfully
nvmlInitialized bool nvmlInitialized bool
...@@ -51,20 +54,9 @@ func (nm *NvidiaManager) Setup() { ...@@ -51,20 +54,9 @@ func (nm *NvidiaManager) Setup() {
return return
} }
nm.initializeNVML() nm.devicesPresent = true
if nm.nvmlInitialized {
return initializeNVML(nm)
}
go func() {
glog.V(2).Info("Starting goroutine to initialize NVML")
// TODO: use globalHousekeepingInterval
for range time.Tick(time.Minute) {
nm.initializeNVML()
if nm.nvmlInitialized {
return
}
}
}()
} }
// detectDevices returns true if a device with given pci id is present on the node. // detectDevices returns true if a device with given pci id is present on the node.
...@@ -91,20 +83,18 @@ func detectDevices(vendorId string) bool { ...@@ -91,20 +83,18 @@ func detectDevices(vendorId string) bool {
} }
// initializeNVML initializes the NVML library and sets up the nvmlDevices map. // initializeNVML initializes the NVML library and sets up the nvmlDevices map.
func (nm *NvidiaManager) initializeNVML() { // This is defined as a variable to help in testing.
var initializeNVML = func(nm *NvidiaManager) {
if err := gonvml.Initialize(); err != nil { if err := gonvml.Initialize(); err != nil {
// This is under a logging level because otherwise we may cause // This is under a logging level because otherwise we may cause
// log spam if the drivers/nvml is not installed on the system. // log spam if the drivers/nvml is not installed on the system.
glog.V(4).Infof("Could not initialize NVML: %v", err) glog.V(4).Infof("Could not initialize NVML: %v", err)
return return
} }
nm.nvmlInitialized = true
numDevices, err := gonvml.DeviceCount() numDevices, err := gonvml.DeviceCount()
if err != nil { if err != nil {
glog.Warningf("GPU metrics would not be available. Failed to get the number of nvidia devices: %v", err) glog.Warningf("GPU metrics would not be available. Failed to get the number of nvidia devices: %v", err)
nm.Lock()
// Even though we won't have GPU metrics, the library was initialized and should be shutdown when exiting.
nm.nvmlInitialized = true
nm.Unlock()
return return
} }
glog.V(1).Infof("NVML initialized. Number of nvidia devices: %v", numDevices) glog.V(1).Infof("NVML initialized. Number of nvidia devices: %v", numDevices)
...@@ -122,10 +112,6 @@ func (nm *NvidiaManager) initializeNVML() { ...@@ -122,10 +112,6 @@ func (nm *NvidiaManager) initializeNVML() {
} }
nm.nvidiaDevices[int(minorNumber)] = device nm.nvidiaDevices[int(minorNumber)] = device
} }
nm.Lock()
// Doing this at the end to avoid race in accessing nvidiaDevices in GetCollector.
nm.nvmlInitialized = true
nm.Unlock()
} }
// Destroy shuts down NVML. // Destroy shuts down NVML.
...@@ -139,12 +125,21 @@ func (nm *NvidiaManager) Destroy() { ...@@ -139,12 +125,21 @@ func (nm *NvidiaManager) Destroy() {
// present in the devices.list file in the given devicesCgroupPath. // present in the devices.list file in the given devicesCgroupPath.
func (nm *NvidiaManager) GetCollector(devicesCgroupPath string) (AcceleratorCollector, error) { func (nm *NvidiaManager) GetCollector(devicesCgroupPath string) (AcceleratorCollector, error) {
nc := &NvidiaCollector{} nc := &NvidiaCollector{}
nm.RLock()
if !nm.devicesPresent {
return nc, nil
}
// Makes sure that we don't call initializeNVML() concurrently and
// that we only call initializeNVML() when it's not initialized.
nm.Lock()
if !nm.nvmlInitialized {
initializeNVML(nm)
}
if !nm.nvmlInitialized || len(nm.nvidiaDevices) == 0 { if !nm.nvmlInitialized || len(nm.nvidiaDevices) == 0 {
nm.RUnlock() nm.Unlock()
return nc, nil return nc, nil
} }
nm.RUnlock() nm.Unlock()
nvidiaMinorNumbers, err := parseDevicesCgroup(devicesCgroupPath) nvidiaMinorNumbers, err := parseDevicesCgroup(devicesCgroupPath)
if err != nil { if err != nil {
return nc, err return nc, err
......
...@@ -81,9 +81,6 @@ type crioContainerHandler struct { ...@@ -81,9 +81,6 @@ type crioContainerHandler struct {
ipAddress string ipAddress string
ignoreMetrics container.MetricSet ignoreMetrics container.MetricSet
// container restart count
restartCount int
} }
var _ container.ContainerHandler = &crioContainerHandler{} var _ container.ContainerHandler = &crioContainerHandler{}
...@@ -175,7 +172,10 @@ func newCrioContainerHandler( ...@@ -175,7 +172,10 @@ func newCrioContainerHandler(
// ignore err and get zero as default, this happens with sandboxes, not sure why... // ignore err and get zero as default, this happens with sandboxes, not sure why...
// kube isn't sending restart count in labels for sandboxes. // kube isn't sending restart count in labels for sandboxes.
restartCount, _ := strconv.Atoi(cInfo.Annotations["io.kubernetes.container.restartCount"]) restartCount, _ := strconv.Atoi(cInfo.Annotations["io.kubernetes.container.restartCount"])
handler.restartCount = restartCount // Only adds restartcount label if it's greater than 0
if restartCount > 0 {
handler.labels["restartcount"] = strconv.Itoa(restartCount)
}
handler.ipAddress = cInfo.IP handler.ipAddress = cInfo.IP
...@@ -225,10 +225,6 @@ func (self *crioContainerHandler) GetSpec() (info.ContainerSpec, error) { ...@@ -225,10 +225,6 @@ func (self *crioContainerHandler) GetSpec() (info.ContainerSpec, error) {
spec, err := common.GetSpec(self.cgroupPaths, self.machineInfoFactory, self.needNet(), hasFilesystem) spec, err := common.GetSpec(self.cgroupPaths, self.machineInfoFactory, self.needNet(), hasFilesystem)
spec.Labels = self.labels spec.Labels = self.labels
// Only adds restartcount label if it's greater than 0
if self.restartCount > 0 {
spec.Labels["restartcount"] = strconv.Itoa(self.restartCount)
}
spec.Envs = self.envs spec.Envs = self.envs
spec.Image = self.image spec.Image = self.image
......
...@@ -115,9 +115,6 @@ type dockerContainerHandler struct { ...@@ -115,9 +115,6 @@ type dockerContainerHandler struct {
// zfs watcher // zfs watcher
zfsWatcher *zfs.ZfsWatcher zfsWatcher *zfs.ZfsWatcher
// container restart count
restartCount int
} }
var _ container.ContainerHandler = &dockerContainerHandler{} var _ container.ContainerHandler = &dockerContainerHandler{}
...@@ -250,7 +247,10 @@ func newDockerContainerHandler( ...@@ -250,7 +247,10 @@ func newDockerContainerHandler(
handler.image = ctnr.Config.Image handler.image = ctnr.Config.Image
handler.networkMode = ctnr.HostConfig.NetworkMode handler.networkMode = ctnr.HostConfig.NetworkMode
handler.deviceID = ctnr.GraphDriver.Data["DeviceId"] handler.deviceID = ctnr.GraphDriver.Data["DeviceId"]
handler.restartCount = ctnr.RestartCount // Only adds restartcount label if it's greater than 0
if ctnr.RestartCount > 0 {
handler.labels["restartcount"] = strconv.Itoa(ctnr.RestartCount)
}
// Obtain the IP address for the contianer. // Obtain the IP address for the contianer.
// If the NetworkMode starts with 'container:' then we need to use the IP address of the container specified. // If the NetworkMode starts with 'container:' then we need to use the IP address of the container specified.
...@@ -386,10 +386,6 @@ func (self *dockerContainerHandler) GetSpec() (info.ContainerSpec, error) { ...@@ -386,10 +386,6 @@ func (self *dockerContainerHandler) GetSpec() (info.ContainerSpec, error) {
spec, err := common.GetSpec(self.cgroupPaths, self.machineInfoFactory, self.needNet(), hasFilesystem) spec, err := common.GetSpec(self.cgroupPaths, self.machineInfoFactory, self.needNet(), hasFilesystem)
spec.Labels = self.labels spec.Labels = self.labels
// Only adds restartcount label if it's greater than 0
if self.restartCount > 0 {
spec.Labels["restartcount"] = strconv.Itoa(self.restartCount)
}
spec.Envs = self.envs spec.Envs = self.envs
spec.Image = self.image spec.Image = self.image
spec.CreationTime = self.creationTime spec.CreationTime = self.creationTime
......
...@@ -533,6 +533,21 @@ func (self *RealFsInfo) GetDirFsDevice(dir string) (*DeviceInfo, error) { ...@@ -533,6 +533,21 @@ func (self *RealFsInfo) GetDirFsDevice(dir string) (*DeviceInfo, error) {
} }
mount, found := self.mounts[dir] mount, found := self.mounts[dir]
// try the parent dir if not found until we reach the root dir
// this is an issue on btrfs systems where the directory is not
// the subvolume
for !found {
pathdir, _ := filepath.Split(dir)
// break when we reach root
if pathdir == "/" {
break
}
// trim "/" from the new parent path otherwise the next possible
// filepath.Split in the loop will not split the string any further
dir = strings.TrimSuffix(pathdir, "/")
mount, found = self.mounts[dir]
}
if found && mount.Fstype == "btrfs" && mount.Major == 0 && strings.HasPrefix(mount.Source, "/dev/") { if found && mount.Fstype == "btrfs" && mount.Major == 0 && strings.HasPrefix(mount.Source, "/dev/") {
major, minor, err := getBtrfsMajorMinorIds(mount) major, minor, err := getBtrfsMajorMinorIds(mount)
if err != nil { if err != nil {
......
...@@ -242,7 +242,7 @@ func retryDockerStatus() info.DockerStatus { ...@@ -242,7 +242,7 @@ func retryDockerStatus() info.DockerStatus {
for { for {
ctx, _ := context.WithTimeout(context.Background(), startupTimeout) ctx, _ := context.WithTimeout(context.Background(), startupTimeout)
dockerStatus, err := docker.StatusWithContext(ctx) dockerStatus, err := docker.StatusWithContext(ctx)
if err != nil { if err == nil {
return dockerStatus return dockerStatus
} }
......
...@@ -110,6 +110,11 @@ func (self *rawContainerWatcher) Stop() error { ...@@ -110,6 +110,11 @@ func (self *rawContainerWatcher) Stop() error {
// Watches the specified directory and all subdirectories. Returns whether the path was // Watches the specified directory and all subdirectories. Returns whether the path was
// already being watched and an error (if any). // already being watched and an error (if any).
func (self *rawContainerWatcher) watchDirectory(dir string, containerName string) (bool, error) { func (self *rawContainerWatcher) watchDirectory(dir string, containerName string) (bool, error) {
// Don't watch .mount cgroups because they never have containers as sub-cgroups. A single container
// can have many .mount cgroups associated with it which can quickly exhaust the inotify watches on a node.
if strings.HasSuffix(containerName, ".mount") {
return false, nil
}
alreadyWatching, err := self.watcher.AddWatch(containerName, dir) alreadyWatching, err := self.watcher.AddWatch(containerName, dir)
if err != nil { if err != nil {
return alreadyWatching, err return alreadyWatching, err
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment