Skip to content

sysfs: treat a missing mdraid uuid as optional - #912

Open
tonycoder-hub wants to merge 1 commit into
prometheus:masterfrom
tonycoder-hub:gb/mdraid-optional-uuid
Open

tonycoder-hub wants to merge 1 commit into
prometheus:masterfrom
tonycoder-hub:gb/mdraid-optional-uuid

Conversation

@tonycoder-hub

Copy link
Copy Markdown

sysfs.Mdraids() returns an error when /sys/block/md*/md/uuid cannot be read. The kernel added that attribute in Linux 5.9, so older kernels (including Synology 3.10 and 4.4) have no uuid file. The error aborts the whole call, and callers lose level, state, disk count, and degraded count as well.

Ignore os.ErrNotExist for uuid and leave Mdraid.UUID empty. Any other read error is still returned.

Fixture array md2 has no uuid file. TestMdraidStats expects that array, including its degraded count, with an empty UUID. Adding it shifts the sysfs block device indexes in blockdevice/stats_test.go, as in #777.

Fixes #907

@SuperQ

/sys/block/md*/md/uuid exists only on Linux 5.9 and later. On older
kernels SysReadFile returned ENOENT and Mdraids() discarded every
array, including level, state, disk count, and degraded count.

Leave UUID empty when the file does not exist and still return any
other error.

Signed-off-by: Tony Coder <407243179@qq.com>
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.

sysfs.Mdraids() fails on kernels before 5.9: md/uuid does not exist

1 participant