node_filesystem_readonly does not report readonly bind mounts correctly
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 Maybe https://github.com/prometheus/node_exporter/issues/3157#issuecomment-2422761187
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?
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.