Bump cadvisor dependencies to latest head.
This commit is contained in:
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)
|
||||
}
|
||||
|
Reference in New Issue
Block a user