Merge pull request #23020 from vishh/godeps-cadvisor

Updating cadvisor deps to v0.22.2
pull/6/head
Phillip Wittrock 2016-03-15 16:53:49 -07:00
commit 57bd9d4289
5 changed files with 77 additions and 99 deletions

72
Godeps/Godeps.json generated
View File

@ -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",

View File

@ -92,7 +92,9 @@ func GetStats(cgroupManager cgroups.Manager, rootFs string, pid int, ignoreMetri
stats := toContainerStats(libcontainerStats)
// If we know the pid then get network stats from /proc/<pid>/net/dev
if pid > 0 {
if pid == 0 {
return stats, nil
}
if !ignoreMetrics.Has(container.NetworkUsageMetrics) {
netStats, err := networkStatsFromProc(rootFs, pid)
if err != nil {
@ -116,7 +118,6 @@ func GetStats(cgroupManager cgroups.Manager, rootFs string, pid int, ignoreMetri
stats.Network.Tcp6 = t6
}
}
}
// For backwards compatibility.
if len(stats.Network.Interfaces) > 0 {

View File

@ -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
}

View File

@ -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)

View File

@ -27,6 +27,7 @@ import (
"github.com/golang/glog"
"github.com/google/cadvisor/cache/memory"
cadvisorMetrics "github.com/google/cadvisor/container"
"github.com/google/cadvisor/events"
cadvisorfs "github.com/google/cadvisor/fs"
cadvisorhttp "github.com/google/cadvisor/http"
@ -66,7 +67,7 @@ func New(port uint) (Interface, error) {
}
// Create and start the cAdvisor container manager.
m, err := manager.New(memory.New(statsCacheDuration, nil), sysFs, maxHousekeepingInterval, allowDynamicHousekeeping)
m, err := manager.New(memory.New(statsCacheDuration, nil), sysFs, maxHousekeepingInterval, allowDynamicHousekeeping, cadvisorMetrics.MetricSet{cadvisorMetrics.NetworkTcpUsageMetrics: struct{}{}})
if err != nil {
return nil, err
}