update cadvisor, docker, and runc godeps
This commit is contained in:
61
vendor/github.com/google/cadvisor/fs/fs.go
generated
vendored
61
vendor/github.com/google/cadvisor/fs/fs.go
generated
vendored
@@ -83,6 +83,8 @@ type RealFsInfo struct {
|
||||
mounts map[string]*mount.Info
|
||||
// devicemapper client
|
||||
dmsetup devicemapper.DmsetupClient
|
||||
// fsUUIDToDeviceName is a map from the filesystem UUID to its device name.
|
||||
fsUUIDToDeviceName map[string]string
|
||||
}
|
||||
|
||||
type Context struct {
|
||||
@@ -103,13 +105,19 @@ func NewFsInfo(context Context) (FsInfo, error) {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
fsUUIDToDeviceName, err := getFsUUIDToDeviceNameMap()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// Avoid devicemapper container mounts - these are tracked by the ThinPoolWatcher
|
||||
excluded := []string{fmt.Sprintf("%s/devicemapper/mnt", context.Docker.Root)}
|
||||
fsInfo := &RealFsInfo{
|
||||
partitions: processMounts(mounts, excluded),
|
||||
labels: make(map[string]string, 0),
|
||||
mounts: make(map[string]*mount.Info, 0),
|
||||
dmsetup: devicemapper.NewDmsetupClient(),
|
||||
partitions: processMounts(mounts, excluded),
|
||||
labels: make(map[string]string, 0),
|
||||
mounts: make(map[string]*mount.Info, 0),
|
||||
dmsetup: devicemapper.NewDmsetupClient(),
|
||||
fsUUIDToDeviceName: fsUUIDToDeviceName,
|
||||
}
|
||||
|
||||
for _, mount := range mounts {
|
||||
@@ -121,11 +129,44 @@ func NewFsInfo(context Context) (FsInfo, error) {
|
||||
// add a "partition" for devicemapper to fsInfo.partitions
|
||||
fsInfo.addDockerImagesLabel(context, mounts)
|
||||
|
||||
glog.Infof("Filesystem UUIDs: %+v", fsInfo.fsUUIDToDeviceName)
|
||||
glog.Infof("Filesystem partitions: %+v", fsInfo.partitions)
|
||||
fsInfo.addSystemRootLabel(mounts)
|
||||
return fsInfo, nil
|
||||
}
|
||||
|
||||
// getFsUUIDToDeviceNameMap creates the filesystem uuid to device name map
|
||||
// using the information in /dev/disk/by-uuid. If the directory does not exist,
|
||||
// this function will return an empty map.
|
||||
func getFsUUIDToDeviceNameMap() (map[string]string, error) {
|
||||
const dir = "/dev/disk/by-uuid"
|
||||
|
||||
if _, err := os.Stat(dir); os.IsNotExist(err) {
|
||||
return make(map[string]string), nil
|
||||
}
|
||||
|
||||
files, err := ioutil.ReadDir(dir)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
fsUUIDToDeviceName := make(map[string]string)
|
||||
for _, file := range files {
|
||||
path := filepath.Join(dir, file.Name())
|
||||
target, err := os.Readlink(path)
|
||||
if err != nil {
|
||||
glog.Infof("Failed to resolve symlink for %q", path)
|
||||
continue
|
||||
}
|
||||
device, err := filepath.Abs(filepath.Join(dir, target))
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to resolve the absolute path of %q", filepath.Join(dir, target))
|
||||
}
|
||||
fsUUIDToDeviceName[file.Name()] = device
|
||||
}
|
||||
return fsUUIDToDeviceName, nil
|
||||
}
|
||||
|
||||
func processMounts(mounts []*mount.Info, excludedMountpointPrefixes []string) map[string]partition {
|
||||
partitions := make(map[string]partition, 0)
|
||||
|
||||
@@ -433,6 +474,18 @@ func minor(devNumber uint64) uint {
|
||||
return uint((devNumber & 0xff) | ((devNumber >> 12) & 0xfff00))
|
||||
}
|
||||
|
||||
func (self *RealFsInfo) GetDeviceInfoByFsUUID(uuid string) (*DeviceInfo, error) {
|
||||
deviceName, found := self.fsUUIDToDeviceName[uuid]
|
||||
if !found {
|
||||
return nil, ErrNoSuchDevice
|
||||
}
|
||||
p, found := self.partitions[deviceName]
|
||||
if !found {
|
||||
return nil, fmt.Errorf("cannot find device %q in partitions", deviceName)
|
||||
}
|
||||
return &DeviceInfo{deviceName, p.major, p.minor}, nil
|
||||
}
|
||||
|
||||
func (self *RealFsInfo) GetDirFsDevice(dir string) (*DeviceInfo, error) {
|
||||
buf := new(syscall.Stat_t)
|
||||
err := syscall.Stat(dir, buf)
|
||||
|
13
vendor/github.com/google/cadvisor/fs/types.go
generated
vendored
13
vendor/github.com/google/cadvisor/fs/types.go
generated
vendored
@@ -14,7 +14,10 @@
|
||||
|
||||
package fs
|
||||
|
||||
import "time"
|
||||
import (
|
||||
"errors"
|
||||
"time"
|
||||
)
|
||||
|
||||
type DeviceInfo struct {
|
||||
Device string
|
||||
@@ -59,6 +62,9 @@ type DiskStats struct {
|
||||
WeightedIoTime uint64
|
||||
}
|
||||
|
||||
// ErrNoSuchDevice is the error indicating the requested device does not exist.
|
||||
var ErrNoSuchDevice = errors.New("cadvisor: no such device")
|
||||
|
||||
type FsInfo interface {
|
||||
// Returns capacity and free space, in bytes, of all the ext2, ext3, ext4 filesystems on the host.
|
||||
GetGlobalFsInfo() ([]Fs, error)
|
||||
@@ -72,6 +78,11 @@ type FsInfo interface {
|
||||
// Returns number of inodes used by 'dir'.
|
||||
GetDirInodeUsage(dir string, timeout time.Duration) (uint64, error)
|
||||
|
||||
// GetDeviceInfoByFsUUID returns the information of the device with the
|
||||
// specified filesystem uuid. If no such device exists, this function will
|
||||
// return the ErrNoSuchDevice error.
|
||||
GetDeviceInfoByFsUUID(uuid string) (*DeviceInfo, error)
|
||||
|
||||
// Returns the block device info of the filesystem on which 'dir' resides.
|
||||
GetDirFsDevice(dir string) (*DeviceInfo, error)
|
||||
|
||||
|
Reference in New Issue
Block a user