From 750c089e6397f0fc0b6f20330a5637c3f7565795 Mon Sep 17 00:00:00 2001 From: Vishnu Kannan Date: Tue, 15 Mar 2016 15:50:19 -0700 Subject: [PATCH] Updating cadvisor deps to v0.22.2 Signed-off-by: Vishnu Kannan --- Godeps/Godeps.json | 72 +++++++++---------- .../container/libcontainer/helpers.go | 43 +++++------ .../google/cadvisor/container/raw/handler.go | 18 ++++- .../google/cadvisor/manager/manager.go | 40 +---------- 4 files changed, 75 insertions(+), 98 deletions(-) diff --git a/Godeps/Godeps.json b/Godeps/Godeps.json index 948e889dca2..4463007b48c 100644 --- a/Godeps/Godeps.json +++ b/Godeps/Godeps.json @@ -578,93 +578,93 @@ }, { "ImportPath": "github.com/google/cadvisor/api", - "Comment": "v0.22.1", - "Rev": "b344feb952c13e0730fa52eb5e5cf1cf7130ee9c" + "Comment": "v0.22.2", + "Rev": "546a3771589bdb356777c646c6eca24914fdd48b" }, { "ImportPath": "github.com/google/cadvisor/cache/memory", - "Comment": "v0.22.1", - "Rev": "b344feb952c13e0730fa52eb5e5cf1cf7130ee9c" + "Comment": "v0.22.2", + "Rev": "546a3771589bdb356777c646c6eca24914fdd48b" }, { "ImportPath": "github.com/google/cadvisor/collector", - "Comment": "v0.22.1", - "Rev": "b344feb952c13e0730fa52eb5e5cf1cf7130ee9c" + "Comment": "v0.22.2", + "Rev": "546a3771589bdb356777c646c6eca24914fdd48b" }, { "ImportPath": "github.com/google/cadvisor/container", - "Comment": "v0.22.1", - "Rev": "b344feb952c13e0730fa52eb5e5cf1cf7130ee9c" + "Comment": "v0.22.2", + "Rev": "546a3771589bdb356777c646c6eca24914fdd48b" }, { "ImportPath": "github.com/google/cadvisor/events", - "Comment": "v0.22.1", - "Rev": "b344feb952c13e0730fa52eb5e5cf1cf7130ee9c" + "Comment": "v0.22.2", + "Rev": "546a3771589bdb356777c646c6eca24914fdd48b" }, { "ImportPath": "github.com/google/cadvisor/fs", - "Comment": "v0.22.1", - "Rev": "b344feb952c13e0730fa52eb5e5cf1cf7130ee9c" + "Comment": "v0.22.2", + "Rev": "546a3771589bdb356777c646c6eca24914fdd48b" }, { "ImportPath": "github.com/google/cadvisor/healthz", - "Comment": "v0.22.1", - "Rev": "b344feb952c13e0730fa52eb5e5cf1cf7130ee9c" + "Comment": "v0.22.2", + "Rev": "546a3771589bdb356777c646c6eca24914fdd48b" }, { "ImportPath": "github.com/google/cadvisor/http", - "Comment": "v0.22.1", - "Rev": "b344feb952c13e0730fa52eb5e5cf1cf7130ee9c" + "Comment": "v0.22.2", + "Rev": "546a3771589bdb356777c646c6eca24914fdd48b" }, { "ImportPath": "github.com/google/cadvisor/info/v1", - "Comment": "v0.22.1", - "Rev": "b344feb952c13e0730fa52eb5e5cf1cf7130ee9c" + "Comment": "v0.22.2", + "Rev": "546a3771589bdb356777c646c6eca24914fdd48b" }, { "ImportPath": "github.com/google/cadvisor/info/v2", - "Comment": "v0.22.1", - "Rev": "b344feb952c13e0730fa52eb5e5cf1cf7130ee9c" + "Comment": "v0.22.2", + "Rev": "546a3771589bdb356777c646c6eca24914fdd48b" }, { "ImportPath": "github.com/google/cadvisor/manager", - "Comment": "v0.22.1", - "Rev": "b344feb952c13e0730fa52eb5e5cf1cf7130ee9c" + "Comment": "v0.22.2", + "Rev": "546a3771589bdb356777c646c6eca24914fdd48b" }, { "ImportPath": "github.com/google/cadvisor/metrics", - "Comment": "v0.22.1", - "Rev": "b344feb952c13e0730fa52eb5e5cf1cf7130ee9c" + "Comment": "v0.22.2", + "Rev": "546a3771589bdb356777c646c6eca24914fdd48b" }, { "ImportPath": "github.com/google/cadvisor/pages", - "Comment": "v0.22.1", - "Rev": "b344feb952c13e0730fa52eb5e5cf1cf7130ee9c" + "Comment": "v0.22.2", + "Rev": "546a3771589bdb356777c646c6eca24914fdd48b" }, { "ImportPath": "github.com/google/cadvisor/storage", - "Comment": "v0.22.1", - "Rev": "b344feb952c13e0730fa52eb5e5cf1cf7130ee9c" + "Comment": "v0.22.2", + "Rev": "546a3771589bdb356777c646c6eca24914fdd48b" }, { "ImportPath": "github.com/google/cadvisor/summary", - "Comment": "v0.22.1", - "Rev": "b344feb952c13e0730fa52eb5e5cf1cf7130ee9c" + "Comment": "v0.22.2", + "Rev": "546a3771589bdb356777c646c6eca24914fdd48b" }, { "ImportPath": "github.com/google/cadvisor/utils", - "Comment": "v0.22.1", - "Rev": "b344feb952c13e0730fa52eb5e5cf1cf7130ee9c" + "Comment": "v0.22.2", + "Rev": "546a3771589bdb356777c646c6eca24914fdd48b" }, { "ImportPath": "github.com/google/cadvisor/validate", - "Comment": "v0.22.1", - "Rev": "b344feb952c13e0730fa52eb5e5cf1cf7130ee9c" + "Comment": "v0.22.2", + "Rev": "546a3771589bdb356777c646c6eca24914fdd48b" }, { "ImportPath": "github.com/google/cadvisor/version", - "Comment": "v0.22.1", - "Rev": "b344feb952c13e0730fa52eb5e5cf1cf7130ee9c" + "Comment": "v0.22.2", + "Rev": "546a3771589bdb356777c646c6eca24914fdd48b" }, { "ImportPath": "github.com/google/gofuzz", diff --git a/Godeps/_workspace/src/github.com/google/cadvisor/container/libcontainer/helpers.go b/Godeps/_workspace/src/github.com/google/cadvisor/container/libcontainer/helpers.go index 674ecdb654c..bcf265866aa 100644 --- a/Godeps/_workspace/src/github.com/google/cadvisor/container/libcontainer/helpers.go +++ b/Godeps/_workspace/src/github.com/google/cadvisor/container/libcontainer/helpers.go @@ -92,29 +92,30 @@ func GetStats(cgroupManager cgroups.Manager, rootFs string, pid int, ignoreMetri stats := toContainerStats(libcontainerStats) // If we know the pid then get network stats from /proc//net/dev - if pid > 0 { - if !ignoreMetrics.Has(container.NetworkUsageMetrics) { - netStats, err := networkStatsFromProc(rootFs, pid) - if err != nil { - glog.V(2).Infof("Unable to get network stats from pid %d: %v", pid, err) - } else { - stats.Network.Interfaces = append(stats.Network.Interfaces, netStats...) - } + if pid == 0 { + return stats, nil + } + if !ignoreMetrics.Has(container.NetworkUsageMetrics) { + netStats, err := networkStatsFromProc(rootFs, pid) + if err != nil { + glog.V(2).Infof("Unable to get network stats from pid %d: %v", pid, err) + } else { + stats.Network.Interfaces = append(stats.Network.Interfaces, netStats...) + } + } + if !ignoreMetrics.Has(container.NetworkTcpUsageMetrics) { + t, err := tcpStatsFromProc(rootFs, pid, "net/tcp") + if err != nil { + glog.V(2).Infof("Unable to get tcp stats from pid %d: %v", pid, err) + } else { + stats.Network.Tcp = t } - if !ignoreMetrics.Has(container.NetworkTcpUsageMetrics) { - t, err := tcpStatsFromProc(rootFs, pid, "net/tcp") - if err != nil { - glog.V(2).Infof("Unable to get tcp stats from pid %d: %v", pid, err) - } else { - stats.Network.Tcp = t - } - t6, err := tcpStatsFromProc(rootFs, pid, "net/tcp6") - if err != nil { - glog.V(2).Infof("Unable to get tcp6 stats from pid %d: %v", pid, err) - } else { - stats.Network.Tcp6 = t6 - } + t6, err := tcpStatsFromProc(rootFs, pid, "net/tcp6") + if err != nil { + glog.V(2).Infof("Unable to get tcp6 stats from pid %d: %v", pid, err) + } else { + stats.Network.Tcp6 = t6 } } diff --git a/Godeps/_workspace/src/github.com/google/cadvisor/container/raw/handler.go b/Godeps/_workspace/src/github.com/google/cadvisor/container/raw/handler.go index 6371eb1128e..94d3141c770 100644 --- a/Godeps/_workspace/src/github.com/google/cadvisor/container/raw/handler.go +++ b/Godeps/_workspace/src/github.com/google/cadvisor/container/raw/handler.go @@ -64,6 +64,12 @@ type rawContainerHandler struct { // Metrics to be ignored. ignoreMetrics container.MetricSet + + pid int +} + +func isRootCgroup(name string) bool { + return name == "/" } func newRawContainerHandler(name string, cgroupSubsystems *libcontainer.CgroupSubsystems, machineInfoFactory info.MachineInfoFactory, fsInfo fs.FsInfo, watcher *InotifyWatcher, rootFs string, ignoreMetrics container.MetricSet) (container.ContainerHandler, error) { @@ -94,6 +100,11 @@ func newRawContainerHandler(name string, cgroupSubsystems *libcontainer.CgroupSu } } + pid := 0 + if isRootCgroup(name) { + pid = 1 + } + return &rawContainerHandler{ name: name, cgroupSubsystems: cgroupSubsystems, @@ -106,6 +117,7 @@ func newRawContainerHandler(name string, cgroupSubsystems *libcontainer.CgroupSu watcher: watcher, rootFs: rootFs, ignoreMetrics: ignoreMetrics, + pid: pid, }, nil } @@ -150,7 +162,7 @@ func readUInt64(dirpath string, file string) uint64 { func (self *rawContainerHandler) GetRootNetworkDevices() ([]info.NetInfo, error) { nd := []info.NetInfo{} - if self.name == "/" { + if isRootCgroup(self.name) { mi, err := self.machineInfoFactory.GetMachineInfo() if err != nil { return nd, err @@ -278,7 +290,7 @@ func (self *rawContainerHandler) GetSpec() (info.ContainerSpec, error) { func (self *rawContainerHandler) getFsStats(stats *info.ContainerStats) error { // Get Filesystem information only for the root cgroup. - if self.name == "/" { + if isRootCgroup(self.name) { filesystems, err := self.fsInfo.GetGlobalFsInfo() if err != nil { return err @@ -341,7 +353,7 @@ func (self *rawContainerHandler) getFsStats(stats *info.ContainerStats) error { } func (self *rawContainerHandler) GetStats() (*info.ContainerStats, error) { - stats, err := libcontainer.GetStats(self.cgroupManager, self.rootFs, os.Getpid(), self.ignoreMetrics) + stats, err := libcontainer.GetStats(self.cgroupManager, self.rootFs, self.pid, self.ignoreMetrics) if err != nil { return stats, err } diff --git a/Godeps/_workspace/src/github.com/google/cadvisor/manager/manager.go b/Godeps/_workspace/src/github.com/google/cadvisor/manager/manager.go index 1c3b551b29c..eb8d2cb9cbb 100644 --- a/Godeps/_workspace/src/github.com/google/cadvisor/manager/manager.go +++ b/Godeps/_workspace/src/github.com/google/cadvisor/manager/manager.go @@ -50,42 +50,6 @@ var eventStorageAgeLimit = flag.String("event_storage_age_limit", "default=24h", var eventStorageEventLimit = flag.String("event_storage_event_limit", "default=100000", "Max number of events to store (per type). Value is a comma separated list of key values, where the keys are event types (e.g.: creation, oom) or \"default\" and the value is an integer. Default is applied to all non-specified event types") var applicationMetricsCountLimit = flag.Int("application_metrics_count_limit", 100, "Max number of application metrics to store (per container)") -var ( - // Metrics to be ignored. - ignoreMetrics metricSetValue = metricSetValue{container.MetricSet{}} - // List of metrics that can be ignored. - ignoreWhitelist = container.MetricSet{ - container.DiskUsageMetrics: struct{}{}, - container.NetworkUsageMetrics: struct{}{}, - container.NetworkTcpUsageMetrics: struct{}{}, - } -) - -func init() { - flag.Var(&ignoreMetrics, "disable_metrics", "comma-separated list of metrics to be disabled. Options are `disk`, `network`, `tcp`. Note: tcp is disabled by default due to high CPU usage.") - // Tcp metrics are ignored by default. - flag.Set("disable_metrics", "tcp") -} - -type metricSetValue struct { - container.MetricSet -} - -func (ml *metricSetValue) String() string { - return fmt.Sprint(*ml) -} - -func (ml *metricSetValue) Set(value string) error { - for _, metric := range strings.Split(value, ",") { - if ignoreWhitelist.Has(container.MetricKind(metric)) { - (*ml).Add(container.MetricKind(metric)) - } else { - return fmt.Errorf("unsupported metric %q specified in disable_metrics", metric) - } - } - return nil -} - // The Manager interface defines operations for starting a manager and getting // container and machine information. type Manager interface { @@ -155,7 +119,7 @@ type Manager interface { } // New takes a memory storage and returns a new manager. -func New(memoryCache *memory.InMemoryCache, sysfs sysfs.SysFs, maxHousekeepingInterval time.Duration, allowDynamicHousekeeping bool) (Manager, error) { +func New(memoryCache *memory.InMemoryCache, sysfs sysfs.SysFs, maxHousekeepingInterval time.Duration, allowDynamicHousekeeping bool, ignoreMetricsSet container.MetricSet) (Manager, error) { if memoryCache == nil { return nil, fmt.Errorf("manager requires memory storage") } @@ -194,7 +158,7 @@ func New(memoryCache *memory.InMemoryCache, sysfs sysfs.SysFs, maxHousekeepingIn startupTime: time.Now(), maxHousekeepingInterval: maxHousekeepingInterval, allowDynamicHousekeeping: allowDynamicHousekeeping, - ignoreMetrics: ignoreMetrics.MetricSet, + ignoreMetrics: ignoreMetricsSet, } machineInfo, err := getMachineInfo(sysfs, fsInfo, inHostNamespace)