node_exporter icon indicating copy to clipboard operation
node_exporter copied to clipboard

node_filesystem_readonly does not report readonly bind mounts correctly

Open codec opened this issue 2 months ago • 1 comments

After upgrading node_exporter from 1.9.1 to 1.10.2, node_filesystem_readonly no longer correctly reports when the same device is mounted multiple times with different flags.

Example: A bind mount that is mounted with ro is now reported as writable.

/dev/sda1 / ext4 rw,relatime 0 0
/dev/sda1 /nix/store ext4 ro,nosuid,nodev,relatime 0 0

Expected behaviour

(with 1.9.1)

node_filesystem_readonly{device="/dev/sda1",device_error="",fstype="ext4",mountpoint="/"} 0
node_filesystem_readonly{device="/dev/sda1",device_error="",fstype="ext4",mountpoint="/nix/store"} 1

Actual behaviour

(with 1.10.2)

node_filesystem_readonly{device="/dev/sda1",device_error="",fstype="ext4",mountpoint="/"} 0
node_filesystem_readonly{device="/dev/sda1",device_error="",fstype="ext4",mountpoint="/nix/store"} 0

codec avatar Nov 22 '25 09:11 codec

@codec Maybe https://github.com/prometheus/node_exporter/issues/3157#issuecomment-2422761187

dongjiang1989 avatar Nov 23 '25 14:11 dongjiang1989

Not sure what is going on, we should consider the super options: https://github.com/prometheus/node_exporter/blob/b306b639e1c81dfd6e142d5415a85b37c9f1c195/collector/filesystem_linux.go#L231

That being said, I can't confirm this issue here. Just upgraded to 1.10.2 and tried with a bind-mount:

mount --bind /pool-mirror-hdd/ /mnt -o ro
mount|grep mirror-hdd
pool-mirror-hdd on /pool-mirror-hdd type zfs (rw,xattr,noacl)
pool-mirror-hdd on /mnt type zfs (ro,xattr,noacl)
curl -s localhost:9100/metrics|grep 'readonly.*mnt'
node_filesystem_readonly{device="pool-mirror-hdd",device_error="",fstype="zfs",mountpoint="/mnt"} 1

@codec Can you try something similar and see if that shows up as read-only? There might be something different in the way nix sets this up?

discordianfish avatar Dec 17 '25 10:12 discordianfish

Ah wait:

mount --bind /pool-mirror-hdd/ /mnt -o ro,nosuid,nodev,relatime
node_filesystem_readonly{device="pool-mirror-hdd",device_error="",fstype="zfs",mountpoint="/mnt"} 0

Ok this is weird, somebody needs to give this a closer look. Nothing obvious wrong with the isFilesystemReadOnly function.

discordianfish avatar Dec 17 '25 10:12 discordianfish