mirror of
				https://github.com/optim-enterprises-bv/kubernetes.git
				synced 2025-11-04 04:08:16 +00:00 
			
		
		
		
	updating cadvisor deps
Signed-off-by: Vishnu kannan <vishnuk@google.com>
This commit is contained in:
		
							
								
								
									
										3
									
								
								vendor/github.com/google/cadvisor/container/container.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										3
									
								
								vendor/github.com/google/cadvisor/container/container.go
									
									
									
										generated
									
									
										vendored
									
									
								
							@@ -59,6 +59,9 @@ type ContainerHandler interface {
 | 
			
		||||
	// Returns container labels, if available.
 | 
			
		||||
	GetContainerLabels() map[string]string
 | 
			
		||||
 | 
			
		||||
	// Returns the container's ip address, if available
 | 
			
		||||
	GetContainerIPAddress() string
 | 
			
		||||
 | 
			
		||||
	// Returns whether the container still exists.
 | 
			
		||||
	Exists() bool
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										23
									
								
								vendor/github.com/google/cadvisor/container/docker/handler.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										23
									
								
								vendor/github.com/google/cadvisor/container/docker/handler.go
									
									
									
										generated
									
									
										vendored
									
									
								
							@@ -94,6 +94,9 @@ type dockerContainerHandler struct {
 | 
			
		||||
	// Filesystem handler.
 | 
			
		||||
	fsHandler common.FsHandler
 | 
			
		||||
 | 
			
		||||
	// The IP address of the container
 | 
			
		||||
	ipAddress string
 | 
			
		||||
 | 
			
		||||
	ignoreMetrics container.MetricSet
 | 
			
		||||
 | 
			
		||||
	// thin pool watcher
 | 
			
		||||
@@ -222,6 +225,22 @@ func newDockerContainerHandler(
 | 
			
		||||
	handler.networkMode = ctnr.HostConfig.NetworkMode
 | 
			
		||||
	handler.deviceID = ctnr.GraphDriver.Data["DeviceId"]
 | 
			
		||||
 | 
			
		||||
	// Obtain the IP address for the contianer.
 | 
			
		||||
	// If the NetworkMode starts with 'container:' then we need to use the IP address of the container specified.
 | 
			
		||||
	// This happens in cases such as kubernetes where the containers doesn't have an IP address itself and we need to use the pod's address
 | 
			
		||||
	ipAddress := ctnr.NetworkSettings.IPAddress
 | 
			
		||||
	networkMode := string(ctnr.HostConfig.NetworkMode)
 | 
			
		||||
	if ipAddress == "" && strings.HasPrefix(networkMode, "container:") {
 | 
			
		||||
		containerId := strings.TrimPrefix(networkMode, "container:")
 | 
			
		||||
		c, err := client.ContainerInspect(context.Background(), containerId)
 | 
			
		||||
		if err != nil {
 | 
			
		||||
			return nil, fmt.Errorf("failed to inspect container %q: %v", id, err)
 | 
			
		||||
		}
 | 
			
		||||
		ipAddress = c.NetworkSettings.IPAddress
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	handler.ipAddress = ipAddress
 | 
			
		||||
 | 
			
		||||
	if !ignoreMetrics.Has(container.DiskUsageMetrics) {
 | 
			
		||||
		handler.fsHandler = &dockerFsHandler{
 | 
			
		||||
			fsHandler:       common.NewFsHandler(time.Minute, rootfsStorageDir, otherStorageDir, fsInfo),
 | 
			
		||||
@@ -412,6 +431,10 @@ func (self *dockerContainerHandler) GetContainerLabels() map[string]string {
 | 
			
		||||
	return self.labels
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (self *dockerContainerHandler) GetContainerIPAddress() string {
 | 
			
		||||
	return self.ipAddress
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (self *dockerContainerHandler) ListProcesses(listType container.ListType) ([]int, error) {
 | 
			
		||||
	return containerlibcontainer.GetProcesses(self.cgroupManager)
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										15
									
								
								vendor/github.com/google/cadvisor/container/libcontainer/helpers.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										15
									
								
								vendor/github.com/google/cadvisor/container/libcontainer/helpers.go
									
									
									
										generated
									
									
										vendored
									
									
								
							@@ -387,23 +387,16 @@ func toContainerStats2(s *cgroups.Stats, ret *info.ContainerStats) {
 | 
			
		||||
		ret.Memory.ContainerData.Pgmajfault = v
 | 
			
		||||
		ret.Memory.HierarchicalData.Pgmajfault = v
 | 
			
		||||
	}
 | 
			
		||||
	if v, ok := s.MemoryStats.Stats["total_inactive_anon"]; ok {
 | 
			
		||||
		workingSet := ret.Memory.Usage
 | 
			
		||||
 | 
			
		||||
	workingSet := ret.Memory.Usage
 | 
			
		||||
	if v, ok := s.MemoryStats.Stats["total_inactive_file"]; ok {
 | 
			
		||||
		if workingSet < v {
 | 
			
		||||
			workingSet = 0
 | 
			
		||||
		} else {
 | 
			
		||||
			workingSet -= v
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		if v, ok := s.MemoryStats.Stats["total_inactive_file"]; ok {
 | 
			
		||||
			if workingSet < v {
 | 
			
		||||
				workingSet = 0
 | 
			
		||||
			} else {
 | 
			
		||||
				workingSet -= v
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
		ret.Memory.WorkingSet = workingSet
 | 
			
		||||
	}
 | 
			
		||||
	ret.Memory.WorkingSet = workingSet
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func toContainerStats3(libcontainerStats *libcontainer.Stats, ret *info.ContainerStats) {
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										119
									
								
								vendor/github.com/google/cadvisor/container/mock.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										119
									
								
								vendor/github.com/google/cadvisor/container/mock.go
									
									
									
										generated
									
									
										vendored
									
									
								
							@@ -1,119 +0,0 @@
 | 
			
		||||
// Copyright 2014 Google Inc. All Rights Reserved.
 | 
			
		||||
//
 | 
			
		||||
// Licensed under the Apache License, Version 2.0 (the "License");
 | 
			
		||||
// you may not use this file except in compliance with the License.
 | 
			
		||||
// You may obtain a copy of the License at
 | 
			
		||||
//
 | 
			
		||||
//     http://www.apache.org/licenses/LICENSE-2.0
 | 
			
		||||
//
 | 
			
		||||
// Unless required by applicable law or agreed to in writing, software
 | 
			
		||||
// distributed under the License is distributed on an "AS IS" BASIS,
 | 
			
		||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 | 
			
		||||
// See the License for the specific language governing permissions and
 | 
			
		||||
// limitations under the License.
 | 
			
		||||
 | 
			
		||||
// +build test
 | 
			
		||||
 | 
			
		||||
package container
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	info "github.com/google/cadvisor/info/v1"
 | 
			
		||||
 | 
			
		||||
	"github.com/stretchr/testify/mock"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
// This struct mocks a container handler.
 | 
			
		||||
type MockContainerHandler struct {
 | 
			
		||||
	mock.Mock
 | 
			
		||||
	Name    string
 | 
			
		||||
	Aliases []string
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func NewMockContainerHandler(containerName string) *MockContainerHandler {
 | 
			
		||||
	return &MockContainerHandler{
 | 
			
		||||
		Name: containerName,
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// If self.Name is not empty, then ContainerReference() will return self.Name and self.Aliases.
 | 
			
		||||
// Otherwise, it will use the value provided by .On().Return().
 | 
			
		||||
func (self *MockContainerHandler) ContainerReference() (info.ContainerReference, error) {
 | 
			
		||||
	if len(self.Name) > 0 {
 | 
			
		||||
		var aliases []string
 | 
			
		||||
		if len(self.Aliases) > 0 {
 | 
			
		||||
			aliases = make([]string, len(self.Aliases))
 | 
			
		||||
			copy(aliases, self.Aliases)
 | 
			
		||||
		}
 | 
			
		||||
		return info.ContainerReference{
 | 
			
		||||
			Name:    self.Name,
 | 
			
		||||
			Aliases: aliases,
 | 
			
		||||
		}, nil
 | 
			
		||||
	}
 | 
			
		||||
	args := self.Called()
 | 
			
		||||
	return args.Get(0).(info.ContainerReference), args.Error(1)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (self *MockContainerHandler) Start() {}
 | 
			
		||||
 | 
			
		||||
func (self *MockContainerHandler) Cleanup() {}
 | 
			
		||||
 | 
			
		||||
func (self *MockContainerHandler) GetSpec() (info.ContainerSpec, error) {
 | 
			
		||||
	args := self.Called()
 | 
			
		||||
	return args.Get(0).(info.ContainerSpec), args.Error(1)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (self *MockContainerHandler) GetStats() (*info.ContainerStats, error) {
 | 
			
		||||
	args := self.Called()
 | 
			
		||||
	return args.Get(0).(*info.ContainerStats), args.Error(1)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (self *MockContainerHandler) ListContainers(listType ListType) ([]info.ContainerReference, error) {
 | 
			
		||||
	args := self.Called(listType)
 | 
			
		||||
	return args.Get(0).([]info.ContainerReference), args.Error(1)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (self *MockContainerHandler) ListProcesses(listType ListType) ([]int, error) {
 | 
			
		||||
	args := self.Called(listType)
 | 
			
		||||
	return args.Get(0).([]int), args.Error(1)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (self *MockContainerHandler) Exists() bool {
 | 
			
		||||
	args := self.Called()
 | 
			
		||||
	return args.Get(0).(bool)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (self *MockContainerHandler) GetCgroupPath(path string) (string, error) {
 | 
			
		||||
	args := self.Called(path)
 | 
			
		||||
	return args.Get(0).(string), args.Error(1)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (self *MockContainerHandler) GetContainerLabels() map[string]string {
 | 
			
		||||
	args := self.Called()
 | 
			
		||||
	return args.Get(0).(map[string]string)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (self *MockContainerHandler) Type() ContainerType {
 | 
			
		||||
	args := self.Called()
 | 
			
		||||
	return args.Get(0).(ContainerType)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
type FactoryForMockContainerHandler struct {
 | 
			
		||||
	Name                        string
 | 
			
		||||
	PrepareContainerHandlerFunc func(name string, handler *MockContainerHandler)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (self *FactoryForMockContainerHandler) String() string {
 | 
			
		||||
	return self.Name
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (self *FactoryForMockContainerHandler) NewContainerHandler(name string, inHostNamespace bool) (ContainerHandler, error) {
 | 
			
		||||
	handler := &MockContainerHandler{}
 | 
			
		||||
	if self.PrepareContainerHandlerFunc != nil {
 | 
			
		||||
		self.PrepareContainerHandlerFunc(name, handler)
 | 
			
		||||
	}
 | 
			
		||||
	return handler, nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (self *FactoryForMockContainerHandler) CanHandle(name string) bool {
 | 
			
		||||
	return true
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										5
									
								
								vendor/github.com/google/cadvisor/container/raw/handler.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										5
									
								
								vendor/github.com/google/cadvisor/container/raw/handler.go
									
									
									
										generated
									
									
										vendored
									
									
								
							@@ -256,6 +256,11 @@ func (self *rawContainerHandler) GetContainerLabels() map[string]string {
 | 
			
		||||
	return map[string]string{}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (self *rawContainerHandler) GetContainerIPAddress() string {
 | 
			
		||||
	// the IP address for the raw container corresponds to the system ip address.
 | 
			
		||||
	return "127.0.0.1"
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (self *rawContainerHandler) ListContainers(listType container.ListType) ([]info.ContainerReference, error) {
 | 
			
		||||
	return common.ListContainers(self.name, self.cgroupPaths, listType)
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										15
									
								
								vendor/github.com/google/cadvisor/container/rkt/handler.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										15
									
								
								vendor/github.com/google/cadvisor/container/rkt/handler.go
									
									
									
										generated
									
									
										vendored
									
									
								
							@@ -250,6 +250,21 @@ func (handler *rktContainerHandler) GetStats() (*info.ContainerStats, error) {
 | 
			
		||||
	return stats, nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (self *rktContainerHandler) GetContainerIPAddress() string {
 | 
			
		||||
	// attempt to return the ip address of the pod
 | 
			
		||||
	// if a specific ip address of the pod could not be determined, return the system ip address
 | 
			
		||||
	if self.isPod && len(self.apiPod.Networks) > 0 {
 | 
			
		||||
		address := self.apiPod.Networks[0].Ipv4
 | 
			
		||||
		if address != "" {
 | 
			
		||||
			return address
 | 
			
		||||
		} else {
 | 
			
		||||
			return self.apiPod.Networks[0].Ipv6
 | 
			
		||||
		}
 | 
			
		||||
	} else {
 | 
			
		||||
		return "127.0.0.1"
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (handler *rktContainerHandler) GetCgroupPath(resource string) (string, error) {
 | 
			
		||||
	path, ok := handler.cgroupPaths[resource]
 | 
			
		||||
	if !ok {
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user