mirror of
https://github.com/rcourtman/Pulse.git
synced 2026-05-05 23:36:37 +00:00
Allow local mergerfs mounts in disk metrics
Stop treating every fuse.* filesystem as a remote mount in the shared disk filter so local user-space filesystems such as mergerfs remain visible to host disk stats and alerts while explicit remote fuse types like sshfs still stay filtered. Refs #1419
This commit is contained in:
parent
730290cc80
commit
7e5971a3ee
3 changed files with 74 additions and 1 deletions
|
|
@ -803,6 +803,75 @@ func TestApplyHostReportFiltersVendorManagedSystemRAIDArrays(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
func TestApplyHostReportKeepsLocalMergerFSMounts(t *testing.T) {
|
||||
t.Helper()
|
||||
|
||||
monitor := &Monitor{
|
||||
state: models.NewState(),
|
||||
alertManager: alerts.NewManager(),
|
||||
hostTokenBindings: make(map[string]string),
|
||||
config: &config.Config{},
|
||||
rateTracker: NewRateTracker(),
|
||||
}
|
||||
t.Cleanup(func() { monitor.alertManager.Stop() })
|
||||
|
||||
report := agentshost.Report{
|
||||
Agent: agentshost.AgentInfo{
|
||||
ID: "agent-mergerfs-host",
|
||||
Version: "1.0.0",
|
||||
IntervalSeconds: 30,
|
||||
},
|
||||
Host: agentshost.HostInfo{
|
||||
ID: "machine-mergerfs-host",
|
||||
Hostname: "mergerfs-host",
|
||||
MachineID: "machine-mergerfs-host",
|
||||
},
|
||||
Disks: []agentshost.Disk{
|
||||
{
|
||||
Device: "mergerfs",
|
||||
Mountpoint: "/mnt/storage",
|
||||
Type: "fuse.mergerfs",
|
||||
TotalBytes: 10_000,
|
||||
UsedBytes: 4_000,
|
||||
FreeBytes: 6_000,
|
||||
Usage: 40,
|
||||
},
|
||||
{
|
||||
Device: "sshfs",
|
||||
Mountpoint: "/mnt/remote",
|
||||
Type: "fuse.sshfs",
|
||||
TotalBytes: 10_000,
|
||||
UsedBytes: 4_000,
|
||||
FreeBytes: 6_000,
|
||||
Usage: 40,
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
host, err := monitor.ApplyHostReport(report, nil)
|
||||
if err != nil {
|
||||
t.Fatalf("ApplyHostReport: %v", err)
|
||||
}
|
||||
|
||||
if len(host.Disks) != 1 {
|
||||
t.Fatalf("host disk count = %d, want 1 (%+v)", len(host.Disks), host.Disks)
|
||||
}
|
||||
if host.Disks[0].Type != "fuse.mergerfs" || host.Disks[0].Mountpoint != "/mnt/storage" {
|
||||
t.Fatalf("unexpected retained disk %+v", host.Disks[0])
|
||||
}
|
||||
|
||||
snapshot := monitor.state.GetSnapshot()
|
||||
if len(snapshot.Hosts) != 1 {
|
||||
t.Fatalf("snapshot host count = %d, want 1", len(snapshot.Hosts))
|
||||
}
|
||||
if len(snapshot.Hosts[0].Disks) != 1 {
|
||||
t.Fatalf("stored host disk count = %d, want 1 (%+v)", len(snapshot.Hosts[0].Disks), snapshot.Hosts[0].Disks)
|
||||
}
|
||||
if snapshot.Hosts[0].Disks[0].Type != "fuse.mergerfs" || snapshot.Hosts[0].Disks[0].Mountpoint != "/mnt/storage" {
|
||||
t.Fatalf("unexpected stored retained disk %+v", snapshot.Hosts[0].Disks[0])
|
||||
}
|
||||
}
|
||||
|
||||
func TestApplyHostReportPersistsSMARTMetricsForAgentDisks(t *testing.T) {
|
||||
t.Helper()
|
||||
|
||||
|
|
|
|||
|
|
@ -84,7 +84,10 @@ var virtualFSTypes = map[string]bool{
|
|||
}
|
||||
|
||||
// networkFSPatterns are substrings that indicate network/remote filesystems.
|
||||
var networkFSPatterns = []string{"fuse", "9p", "nfs", "cifs", "smb"}
|
||||
// Do not treat generic "fuse" as remote: some FUSE filesystems such as
|
||||
// mergerfs are local user-space filesystems and should participate in host
|
||||
// disk usage and alerting just like ext4/xfs mounts.
|
||||
var networkFSPatterns = []string{"sshfs", "9p", "nfs", "cifs", "smb"}
|
||||
|
||||
// specialMountPrefixes are mountpoint prefixes that indicate system mounts.
|
||||
var specialMountPrefixes = []string{
|
||||
|
|
|
|||
|
|
@ -165,6 +165,7 @@ func TestShouldSkipFilesystem(t *testing.T) {
|
|||
{"cifs mount", "cifs", "/mnt/share", 1000000, 500000, true},
|
||||
{"fuse.sshfs", "fuse.sshfs", "/mnt/remote", 1000000, 500000, true},
|
||||
{"9p VM shared folder", "9p", "/mnt/host", 1000000, 500000, true},
|
||||
{"fuse.mergerfs local pool", "fuse.mergerfs", "/mnt/storage", 1000000, 500000, false},
|
||||
|
||||
// Special mountpoint prefixes
|
||||
{"/dev prefix", "ext4", "/dev/shm", 1024, 100, true},
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue