update cAdvisor godeps to v0.34.0 release

This commit is contained in:
David Ashpole 2019-08-30 10:31:03 -07:00
parent afa979c295
commit 5420d84160
6 changed files with 49 additions and 6 deletions

4
go.mod
View File

@ -66,7 +66,7 @@ require (
github.com/golang/groupcache v0.0.0-20160516000752-02826c3e7903
github.com/golang/mock v1.2.0
github.com/golang/protobuf v1.3.1
github.com/google/cadvisor v0.33.2-0.20190719172907-9fa3b1429966
github.com/google/cadvisor v0.34.0
github.com/google/certificate-transparency-go v1.0.21 // indirect
github.com/google/go-cmp v0.3.0
github.com/google/gofuzz v1.0.0
@ -282,7 +282,7 @@ replace (
github.com/golangplus/fmt => github.com/golangplus/fmt v0.0.0-20150411045040-2a5d6d7d2995
github.com/golangplus/testing => github.com/golangplus/testing v0.0.0-20180327235837-af21d9c3145e
github.com/google/btree => github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c
github.com/google/cadvisor => github.com/google/cadvisor v0.33.2-0.20190719172907-9fa3b1429966
github.com/google/cadvisor => github.com/google/cadvisor v0.34.0
github.com/google/certificate-transparency-go => github.com/google/certificate-transparency-go v1.0.21
github.com/google/go-cmp => github.com/google/go-cmp v0.3.0
github.com/google/gofuzz => github.com/google/gofuzz v1.0.0

4
go.sum
View File

@ -200,8 +200,8 @@ github.com/golangplus/testing v0.0.0-20180327235837-af21d9c3145e h1:KhcknUwkWHKZ
github.com/golangplus/testing v0.0.0-20180327235837-af21d9c3145e/go.mod h1:0AA//k/eakGydO4jKRoRL2j92ZKSzTgj9tclaCrvXHk=
github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c h1:964Od4U6p2jUkFxvCydnIczKteheJEzHRToSGK3Bnlw=
github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ=
github.com/google/cadvisor v0.33.2-0.20190719172907-9fa3b1429966 h1:8PpCh6R0YjmmztPXOq9aKhiUqLGUrp6Fly3vWk7l2Fg=
github.com/google/cadvisor v0.33.2-0.20190719172907-9fa3b1429966/go.mod h1:1nql6U13uTHaLYB8rLS5x9IJc2qT6Xd/Tr1sTX6NE48=
github.com/google/cadvisor v0.34.0 h1:No7G6U/TasplR9uNqyc5Jj0Bet5VSYsK5xLygOf4pUw=
github.com/google/cadvisor v0.34.0/go.mod h1:1nql6U13uTHaLYB8rLS5x9IJc2qT6Xd/Tr1sTX6NE48=
github.com/google/certificate-transparency-go v1.0.21 h1:Yf1aXowfZ2nuboBsg7iYGLmwsOARdV86pfH3g95wXmE=
github.com/google/certificate-transparency-go v1.0.21/go.mod h1:QeJfpSbVSfYc7RgB3gJFj9cbuQMMchQxrWXz8Ruopmg=
github.com/google/go-cmp v0.3.0 h1:crn/baboCvb5fXaQ0IJ1SGTsTVrWpDsCWC8EGETZijY=

View File

@ -33,6 +33,9 @@ import (
)
type crioContainerHandler struct {
client crioClient
name string
machineInfoFactory info.MachineInfoFactory
// Absolute path to the cgroup hierarchies of this container.
@ -68,6 +71,9 @@ type crioContainerHandler struct {
reference info.ContainerReference
libcontainerHandler *containerlibcontainer.Handler
cgroupManager *cgroupfs.Manager
rootFs string
pidKnown bool
}
var _ container.ContainerHandler = &crioContainerHandler{}
@ -103,11 +109,20 @@ func newCrioContainerHandler(
}
id := ContainerNameToCrioId(name)
pidKnown := true
cInfo, err := client.ContainerInfo(id)
if err != nil {
return nil, err
}
if cInfo.Pid == 0 {
// If pid is not known yet, network related stats can not be retrieved by the
// libcontainer handler GetStats(). In this case, the crio handler GetStats()
// will reattempt to get the pid and, if now known, will construct the libcontainer
// handler. This libcontainer handler is then cached and reused without additional
// calls to crio.
pidKnown = false
}
// passed to fs handler below ...
// XXX: this is using the full container logpath, as constructed by the CRI
@ -142,6 +157,8 @@ func newCrioContainerHandler(
// TODO: extract object mother method
handler := &crioContainerHandler{
client: client,
name: name,
machineInfoFactory: machineInfoFactory,
cgroupPaths: cgroupPaths,
storageDriver: storageDriver,
@ -152,6 +169,9 @@ func newCrioContainerHandler(
includedMetrics: includedMetrics,
reference: containerReference,
libcontainerHandler: libcontainerHandler,
cgroupManager: cgroupManager,
rootFs: rootFs,
pidKnown: pidKnown,
}
handler.image = cInfo.Image
@ -263,8 +283,27 @@ func (self *crioContainerHandler) getFsStats(stats *info.ContainerStats) error {
return nil
}
func (self *crioContainerHandler) getLibcontainerHandler() *containerlibcontainer.Handler {
if self.pidKnown {
return self.libcontainerHandler
}
id := ContainerNameToCrioId(self.name)
cInfo, err := self.client.ContainerInfo(id)
if err != nil || cInfo.Pid == 0 {
return self.libcontainerHandler
}
self.pidKnown = true
self.libcontainerHandler = containerlibcontainer.NewHandler(self.cgroupManager, self.rootFs, cInfo.Pid, self.includedMetrics)
return self.libcontainerHandler
}
func (self *crioContainerHandler) GetStats() (*info.ContainerStats, error) {
stats, err := self.libcontainerHandler.GetStats()
libcontainerHandler := self.getLibcontainerHandler()
stats, err := libcontainerHandler.GetStats()
if err != nil {
return stats, err
}

View File

@ -30,6 +30,7 @@ import (
)
var dockerOnly = flag.Bool("docker_only", false, "Only report docker containers in addition to root stats")
var disableRootCgroupStats = flag.Bool("disable_root_cgroup_stats", false, "Disable collecting root Cgroup stats")
type rawFactory struct {
// Factory for machine information.

View File

@ -227,6 +227,9 @@ func (self *rawContainerHandler) getFsStats(stats *info.ContainerStats) error {
}
func (self *rawContainerHandler) GetStats() (*info.ContainerStats, error) {
if *disableRootCgroupStats && isRootCgroup(self.name) {
return nil, nil
}
stats, err := self.libcontainerHandler.GetStats()
if err != nil {
return stats, err

2
vendor/modules.txt vendored
View File

@ -435,7 +435,7 @@ github.com/golang/protobuf/ptypes/timestamp
github.com/golang/protobuf/ptypes/wrappers
# github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c => github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c
github.com/google/btree
# github.com/google/cadvisor v0.33.2-0.20190719172907-9fa3b1429966 => github.com/google/cadvisor v0.33.2-0.20190719172907-9fa3b1429966
# github.com/google/cadvisor v0.34.0 => github.com/google/cadvisor v0.34.0
github.com/google/cadvisor/accelerators
github.com/google/cadvisor/cache/memory
github.com/google/cadvisor/client/v2