Skip to content

Commit

Permalink
fixed: issue in the storage sampler where we reported only one mountp…
Browse files Browse the repository at this point in the history
…oint for each device.
  • Loading branch information
cristianciutea authored and carlosroman committed Aug 14, 2020
1 parent a7b17c6 commit 71cc96b
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions pkg/metrics/storage/storage_sampler_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ func pidForProcMounts(isContainerized bool) string {
// use /etc/mtab because /proc/<pid>/mounts doesn't display properly lvm
// devices, making it impossible to match against io counters.
// The same logic is applied in fetchPartitions.
func deviceMapperInfo(isContainerized bool) map[string]MountInfoStat {
func deviceMapperInfo(isContainerized bool) (mounts []MountInfoStat) {
var mountsFile string
var mountsFilePath string

Expand All @@ -319,7 +319,6 @@ func deviceMapperInfo(isContainerized bool) map[string]MountInfoStat {
return nil
}

devices := make(map[string]MountInfoStat)
for lineno, line := range lines {
mountInfo, err := parseMountFile(mountsFile, line)
if err != nil {
Expand All @@ -343,10 +342,10 @@ func deviceMapperInfo(isContainerized bool) map[string]MountInfoStat {
continue
}
// nil = unsupported fs
devices[mountInfo.Device] = mountInfo
mounts = append(mounts, mountInfo)
}

return devices
return
}

// CalculateDeviceMapping maps devices found in mount information file to diskstats device name format
Expand All @@ -364,7 +363,10 @@ func CalculateDeviceMapping(activeDevices map[string]bool, isContainerized bool)
for deviceName := range activeDevices {
_, isLvm := isLvmMount(deviceName)
if isLvm {
if mi, found := allMounts[deviceName]; found {
for _, mi := range allMounts {
if mi.MountSource != deviceName {
continue
}
var devNumbers []string
// if we have MajMin, use it, otherwise try with a regex based on the name
if len(mi.MajMin) > 0 {
Expand All @@ -381,7 +383,10 @@ func CalculateDeviceMapping(activeDevices map[string]bool, isContainerized bool)

// mapped device name. ex: dm-x -> /dev/mapper/xxx
deviceKey := fmt.Sprintf("dm-%s", devNumbers[1])

devToFullDevicePath[deviceKey] = deviceName

break
}
} else {
match := deviceRegexp.FindStringSubmatch(deviceName)
Expand Down

0 comments on commit 71cc96b

Please sign in to comment.