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

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
}