mirror of
https://github.com/google/cadvisor.git
synced 2021-05-12 18:32:21 +03:00
Add support for non btrfs devices in GetDirFsDevice
We can create a `*DeviceInfo` from the mount even if the `FSType` is not `btrfs`. Signed-off-by: Sascha Grunert <sgrunert@redhat.com>
This commit is contained in:
17
fs/fs.go
17
fs/fs.go
@@ -582,14 +582,19 @@ func (i *RealFsInfo) GetDirFsDevice(dir string) (*DeviceInfo, error) {
|
||||
}
|
||||
|
||||
mnt, found := i.mountInfoFromDir(dir)
|
||||
if found && mnt.FSType == "btrfs" && mnt.Major == 0 && strings.HasPrefix(mnt.Source, "/dev/") {
|
||||
major, minor, err := getBtrfsMajorMinorIds(mnt)
|
||||
if err != nil {
|
||||
klog.Warningf("%s", err)
|
||||
} else {
|
||||
return &DeviceInfo{mnt.Source, uint(major), uint(minor)}, nil
|
||||
if found && strings.HasPrefix(mnt.Source, "/dev/") {
|
||||
major, minor := mnt.Major, mnt.Minor
|
||||
|
||||
if mnt.FSType == "btrfs" && major == 0 {
|
||||
major, minor, err = getBtrfsMajorMinorIds(mnt)
|
||||
if err != nil {
|
||||
klog.Warningf("Unable to get btrfs mountpoint IDs: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
return &DeviceInfo{mnt.Source, uint(major), uint(minor)}, nil
|
||||
}
|
||||
|
||||
return nil, fmt.Errorf("could not find device with major: %d, minor: %d in cached partitions map", major, minor)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user