Skip to content

blockdevice: add DMMultipathDevices for DM-multipath sysfs parsing#796

Open
sradco wants to merge 1 commit intoprometheus:masterfrom
sradco:add-dmmultipath-sysfs-parsing
Open

blockdevice: add DMMultipathDevices for DM-multipath sysfs parsing#796
sradco wants to merge 1 commit intoprometheus:masterfrom
sradco:add-dmmultipath-sysfs-parsing

Conversation

@sradco
Copy link

@sradco sradco commented Mar 15, 2026

Add DMMultipathDevices() method to blockdevice.FS that discovers Device Mapper multipath devices by scanning /sys/block/dm-* and filtering on dm/uuid prefix "mpath-". For each multipath device it reads the device name, UUID, suspended state, size, and enumerates underlying path devices with their raw state from
/sys/block//device/state.

This provides the sysfs parsing layer that node_exporter's dmmultipath collector will import, following the established pattern where collectors delegate filesystem parsing to procfs.

This is the parsing layer for prometheus/node_exporter#3581

}

suspended := false
if val, err := util.ReadUintFromFile(fs.sys.Path(sysBlockPath, entry.Name(), sysBlockDM, "suspended")); err == nil {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code looks good overall - it reads the right values from the right sysfs files.

The only thing I noticed is that stats.go returns error on any Read / parse errors, while this file ignores them. I let Prometheus folks judge what's right here.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typically we don't ignore errors and try and pass them back so the user of the library can decide what to do about errors.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1. Thanks.
I updated the PR now with the fix.

Add DMMultipathDevices() method to blockdevice.FS that discovers
Device Mapper multipath devices by scanning /sys/block/dm-* and
filtering on dm/uuid prefix "mpath-". For each multipath device it
reads the device name, UUID, suspended state, size, and enumerates
underlying path devices with their raw state from
/sys/block/<path>/device/state.

This provides the sysfs parsing layer that node_exporter's
dmmultipath collector will import, following the established pattern
where collectors delegate filesystem parsing to procfs.

Signed-off-by: Shirly Radco <sradco@redhat.com>
Co-authored-by: AI Assistant <noreply@cursor.com>
@sradco sradco force-pushed the add-dmmultipath-sysfs-parsing branch from 7e7c41d to a8a28fe Compare March 16, 2026 10:26
@sradco
Copy link
Author

sradco commented Mar 18, 2026

Hi @SuperQ @jsafrane , I updated the PR based on your feedback. Please review.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants