Fix mount points being collected multiple times in filesystem_linux #3376
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hi,
this PR attempts to address #2805.
The issue we encountered is a case in which a path is bind-mounted to itself, the same issue you can see in this latest comment.
NixOS bind-mounts the
/nix/store
path to/nix/store
to remount the same mount read-only and (nosuid, nodev), as you can see here. If the/nix/store
path is already a mount from some device, this will lead to metrics being collected twice for the same (mountPoint, device) combination if the mount options differ.This issue only occurs, when the filesystem options of the two mounts are different. The core issue is, that the existing filter that wants to prevent this issue here takes the entire
labels
struct into account, including mount options.The mount options themselves are not used or exposed by node_exporter. So this minimal fix only removes the filesystem options after they are used to extract the
ro
gauge. This way, theseen := map[filesystemLabels]bool{}
filter works correctly (as the options are always""
).This has a side-effect: Previously, the
ro
gauge was exported twice in this case, if the two mounts were read only and read-write (oncero
, oncerw
). Now, the gauge is exported only once and in the example, it would be exportedrw
, even though the mount actually used by the kernel (the upper mount), isro
.Additional options we came up with to fix this:
options
fromfileSystemLabels
alltogether (only used in Linux anyway).ro
state.ro
option to gauges as a label.@discordianfish You were involved in the original issue. What do you think?