mirror of
				https://github.com/k3s-io/kubernetes.git
				synced 2025-11-03 23:40:03 +00:00 
			
		
		
		
	update cAdvisor godeps to v0.34.0 release
This commit is contained in:
		
							
								
								
									
										41
									
								
								vendor/github.com/google/cadvisor/container/crio/handler.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										41
									
								
								vendor/github.com/google/cadvisor/container/crio/handler.go
									
									
									
										generated
									
									
										vendored
									
									
								
							@@ -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
 | 
			
		||||
	}
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										1
									
								
								vendor/github.com/google/cadvisor/container/raw/factory.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										1
									
								
								vendor/github.com/google/cadvisor/container/raw/factory.go
									
									
									
										generated
									
									
										vendored
									
									
								
							@@ -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.
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										3
									
								
								vendor/github.com/google/cadvisor/container/raw/handler.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										3
									
								
								vendor/github.com/google/cadvisor/container/raw/handler.go
									
									
									
										generated
									
									
										vendored
									
									
								
							@@ -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
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user