Real-time monitoring dashboard for Proxmox VE, PBS, Docker, Kubernetes, TrueNAS and vSphere. Self-hosted, with alerts for failed backups, full disks, unhealthy containers and offline nodes.
Go aialertsdashboarddockerdocker-monitoringgohomelabinfrastructure-monitoringkubernetesmonitoringmspproxmoxproxmox-backup-serverproxmox-mail-gatewayproxmox-veself-hostedtruenastypescriptvspherewebhooks
Reject case-variant guest filesystem identity fields
pulse-triage[bot]e7d8092c633a
diff --git a/docs/release-control/v6/internal/subsystems/monitoring.md b/docs/release-control/v6/internal/subsystems/monitoring.mdindex 6178dec032..c552c837a2 100644--- a/docs/release-control/v6/internal/subsystems/monitoring.md+++ b/docs/release-control/v6/internal/subsystems/monitoring.md@@ -6847,6 +6847,17 @@ retains its four-minute Proxmox threshold.### Incomplete guest filesystem responses do not establish recovery+Filesystem record identity/filter fields (`name`, `type`, `mountpoint`, `disk`)+use the same exact canonical key rule as byte counters. Case-variant keys must+not exploit JSON's case-insensitive matching to overwrite a mount/device or+make a real volume appear special and silently removed. They reject that row+as incomplete regardless of field order or whether the canonical key is also+present. Exact JSON-escaped canonical keys and unrelated additive fields remain+compatible. `TestVMFilesystemMetadataRejectsNoncanonicalFields` and+`TestVMFilesystemMetadataPreservesCanonicalCompatibility` pin that boundary;+the connected completeness fixtures cover direct/cluster clients and both+collectors through held/expired evidence and genuine ordinary recovery.+`GetVMFSInfo` preserves valid peer rows from a malformed array but returns anerror with them, through both single and cluster clients. The surviving rowscannot establish total guest capacity, usage, or removal of a rejected volume.diff --git a/internal/monitoring/guest_filesystem_completeness_test.go b/internal/monitoring/guest_filesystem_completeness_test.goindex ee2c6e308f..d4e53a1aa2 100644--- a/internal/monitoring/guest_filesystem_completeness_test.go+++ b/internal/monitoring/guest_filesystem_completeness_test.go@@ -59,8 +59,15 @@ func TestVMFilesystemIncompleteAlternateClientCannotPublishRemainder(t *testing.// Exercise both collectors, canonical previous state, served JSON, History and// genuine filesystem alerts. No guest freeze, command bypass or native probe.func TestVMFilesystemIncompletePollingPreservesHistoryAndBreach(t *testing.T) {- for _, path := range []string{"cluster", "node"} {- t.Run(path, func(t *testing.T) {+ for _, tc := range []struct{ name, collector, badRow string }{+ {"cluster", "cluster", `{"mountpoint":"/data","type":"ext4","total-bytes":9000}`},+ {"node", "node", `{"mountpoint":"/data","type":"ext4","total-bytes":9000}`},+ {"cluster-case-mount", "cluster", `{"mountpoint":"/data","MOUNTPOINT":"/proc","type":"ext4","disk":[{"dev":"/dev/vdb1"}],"total-bytes":9000,"used-bytes":8820}`},+ {"node-case-mount", "node", `{"mountpoint":"/data","MOUNTPOINT":"/proc","type":"ext4","disk":[{"dev":"/dev/vdb1"}],"total-bytes":9000,"used-bytes":8820}`},+ {"cluster-case-type", "cluster", `{"mountpoint":"/data","type":"ext4","TYPE":"tmpfs","disk":[{"dev":"/dev/vdb1"}],"total-bytes":9000,"used-bytes":8820}`},+ {"node-case-type", "node", `{"mountpoint":"/data","type":"ext4","TYPE":"tmpfs","disk":[{"dev":"/dev/vdb1"}],"total-bytes":9000,"used-bytes":8820}`},+ } {+ t.Run(tc.name, func(t *testing.T) {var phase, fsCalls atomic.Int32server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {w.Header().Set("Content-Type", "application/json")@@ -74,7 +81,7 @@ func TestVMFilesystemIncompletePollingPreservesHistoryAndBreach(t *testing.T) {rows := `{"mountpoint":"/","type":"ext4","disk":[{"dev":"/dev/vda1"}],"total-bytes":1000,"used-bytes":980},{"mountpoint":"/data","type":"ext4","disk":[{"dev":"/dev/vdb1"}],"total-bytes":9000,"used-bytes":8820}`switch phase.Load() {case 1:- rows = `{"mountpoint":"/","type":"ext4","disk":[{"dev":"/dev/vda1"}],"total-bytes":1000,"used-bytes":0},{"mountpoint":"/data","type":"ext4","total-bytes":9000}`+ rows = `{"mountpoint":"/","type":"ext4","disk":[{"dev":"/dev/vda1"}],"total-bytes":1000,"used-bytes":0},` + tc.badRowcase 2:rows = `{"mountpoint":"/","type":"ext4","disk":[{"dev":"/dev/vda1"}],"total-bytes":1000,"used-bytes":0}`}@@ -112,7 +119,7 @@ func TestVMFilesystemIncompletePollingPreservesHistoryAndBreach(t *testing.T) {t.Helper()previous := m.previousGuestContextForInstance("partial-filesystems").vmsByID[id]var vm models.VM- if path == "node" {+ if tc.collector == "node" {vms, _ := m.pollNodeVMsWithClusterResourceBuilder(context.Background(), "partial-filesystems", "node", []proxmox.VM{{VMID: 105, Name: res.Name, Status: res.Status, MaxMem: res.MaxMem, Mem: res.Mem, MaxDisk: res.MaxDisk, CPU: res.CPU}}, client, map[string]models.VM{id: previous}, nil)if len(vms) != 1 {t.Fatal("node collector lost guest")diff --git a/pkg/proxmox/client.go b/pkg/proxmox/client.goindex ccca7b3c56..47f6a75a43 100644--- a/pkg/proxmox/client.go+++ b/pkg/proxmox/client.go@@ -1708,13 +1708,14 @@ func (fs *VMFileSystem) UnmarshalJSON(data []byte) error {}recognized := falsefor name := range fields {- switch name {- case "name", "type", "mountpoint", "total-bytes", "total-bytes-privileged", "used-bytes", "disk":- recognized = true- }- for _, canonical := range []string{"total-bytes", "total-bytes-privileged", "used-bytes"} {- if name != canonical && strings.EqualFold(name, canonical) {- return fmt.Errorf("guest filesystem byte count has a noncanonical field name")+ // encoding/json also matches case-insensitive struct fields. Identity+ // and filter metadata must not overwrite an earlier canonical field or+ // turn a rejected volume into a special mount that silently disappears.+ for _, canonical := range []string{"name", "type", "mountpoint", "total-bytes", "total-bytes-privileged", "used-bytes", "disk"} {+ if name == canonical {+ recognized = true+ } else if strings.EqualFold(name, canonical) {+ return fmt.Errorf("guest filesystem record has a noncanonical field name")}}}diff --git a/pkg/proxmox/guest_filesystem_bytes_test.go b/pkg/proxmox/guest_filesystem_bytes_test.goindex 82f9b17340..bcd435e470 100644--- a/pkg/proxmox/guest_filesystem_bytes_test.go+++ b/pkg/proxmox/guest_filesystem_bytes_test.go@@ -89,10 +89,14 @@ func TestVMFilesystemBytesWireAdmissionKeepsValidPeersAndObjectPrecision(t *testtotal, used uint64wantError bool}{- "array-peers": {`[{"mountpoint":"/bad","type":"ext4","total-bytes":1000},{"mountpoint":"/negative","type":"ext4","total-bytes":1000,"used-bytes":-1},{"mountpoint":"/overfull","type":"ext4","total-bytes":1000,"used-bytes":1001},{"mountpoint":"/","type":"ext4","total-bytes":1000,"used-bytes":0}]`, 1000, 0, true},- "object-precision": {`{"mountpoint":"C:\\","type":"ntfs","total-bytes":9007199254740993,"used-bytes":9007199254740991,"disk":{"bus-type":"scsi","target":2}}`, 9007199254740993, 9007199254740991, false},- "object-duplicate": {`{"mountpoint":"C:\\","type":"ntfs","total-bytes":1000,"used-bytes":1001,"used-bytes":0}`, 0, 0, true},- "object-missing": {`{"mountpoint":"C:\\","type":"ntfs","total-bytes":1000}`, 0, 0, true},+ "array-peers": {`[{"mountpoint":"/bad","type":"ext4","total-bytes":1000},{"mountpoint":"/negative","type":"ext4","total-bytes":1000,"used-bytes":-1},{"mountpoint":"/overfull","type":"ext4","total-bytes":1000,"used-bytes":1001},{"mountpoint":"/","type":"ext4","total-bytes":1000,"used-bytes":0}]`, 1000, 0, true},+ "object-precision": {`{"mountpoint":"C:\\","type":"ntfs","total-bytes":9007199254740993,"used-bytes":9007199254740991,"disk":{"bus-type":"scsi","target":2}}`, 9007199254740993, 9007199254740991, false},+ "object-duplicate": {`{"mountpoint":"C:\\","type":"ntfs","total-bytes":1000,"used-bytes":1001,"used-bytes":0}`, 0, 0, true},+ "object-missing": {`{"mountpoint":"C:\\","type":"ntfs","total-bytes":1000}`, 0, 0, true},+ "object-case-name": {`{"name":"/dev/vdb1","NAME":"C:\\","mountpoint":"/data","type":"ext4","total-bytes":1000,"used-bytes":0}`, 0, 0, true},+ "object-case-type": {`{"mountpoint":"/data","type":"ext4","Type":"tmpfs","total-bytes":1000,"used-bytes":0}`, 0, 0, true},+ "object-case-mount": {`{"mountpoint":"/data","Mountpoint":"/proc","type":"ext4","total-bytes":1000,"used-bytes":0}`, 0, 0, true},+ "object-case-disk": {`{"mountpoint":"/data","type":"ext4","disk":[{"dev":"/dev/vdb1"}],"Disk":[{"dev":"/dev/vda1"}],"total-bytes":1000,"used-bytes":0}`, 0, 0, true},} {t.Run(name, func(t *testing.T) {var calls atomic.Int32diff --git a/pkg/proxmox/guest_filesystem_completeness_test.go b/pkg/proxmox/guest_filesystem_completeness_test.goindex 0226d6a304..ebbde0bdfb 100644--- a/pkg/proxmox/guest_filesystem_completeness_test.go+++ b/pkg/proxmox/guest_filesystem_completeness_test.go@@ -25,6 +25,10 @@ func TestVMFilesystemIncompleteInventoryKeepsPeersAndSingleAttempt(t *testing.T)"scalar-record": `42`,"empty-record": `{}`,"unknown-record": `{"unknown":"value"}`,+ "case-name": `{"name":"/dev/vdb1","NAME":"C:\\","mountpoint":"/data","type":"ext4","total-bytes":9000,"used-bytes":8820}`,+ "case-type": `{"mountpoint":"/data","type":"ext4","TYPE":"tmpfs","total-bytes":9000,"used-bytes":8820}`,+ "case-mount": `{"mountpoint":"/data","MOUNTPOINT":"/proc","type":"ext4","total-bytes":9000,"used-bytes":8820}`,+ "case-disk": `{"mountpoint":"/data","type":"ext4","disk":[{"dev":"/dev/vdb1"}],"DISK":[{"dev":"/dev/vda1"}],"total-bytes":9000,"used-bytes":8820}`,} {t.Run(path+"/"+name, func(t *testing.T) {var commands, configs atomic.Int32diff --git a/pkg/proxmox/guest_filesystem_metadata_test.go b/pkg/proxmox/guest_filesystem_metadata_test.gonew file mode 100644index 0000000000..b3046791c4--- /dev/null+++ b/pkg/proxmox/guest_filesystem_metadata_test.go@@ -0,0 +1,62 @@+package proxmox++import (+ "encoding/json"+ "fmt"+ "strings"+ "testing"+)++func TestVMFilesystemMetadataRejectsNoncanonicalFields(t *testing.T) {+ fields := []struct{ name, value, replacement string }{+ {"name", `"/dev/vdb1"`, `"C:\\"`},+ {"type", `"ext4"`, `"tmpfs"`},+ {"mountpoint", `"/data"`, `"/proc"`},+ {"disk", `[{"dev":"/dev/vdb1"}]`, `[{"dev":"/dev/vda1"}]`},+ }+ for _, field := range fields {+ for _, alias := range []string{strings.ToUpper(field.name), strings.ToUpper(field.name[:1]) + field.name[1:]} {+ t.Run(field.name+"/"+alias, func(t *testing.T) {+ base := `"total-bytes":9000,"used-bytes":8820`+ for _, peer := range fields {+ if peer.name != field.name {+ base += fmt.Sprintf(",%q:%s", peer.name, peer.value)+ }+ }+ canonical := fmt.Sprintf("%q:%s", field.name, field.value)+ variant := fmt.Sprintf("%q:%s", alias, field.replacement)+ for name, suffix := range map[string]string{+ "alias-only": variant,+ "canonical-first": canonical + "," + variant,+ "canonical-last": variant + "," + canonical,+ } {+ t.Run(name, func(t *testing.T) {+ var fs VMFileSystem+ if err := json.Unmarshal([]byte("{"+base+","+suffix+"}"), &fs); err == nil {+ t.Fatalf("case-variant metadata became a complete filesystem reading: %+v", fs)+ }+ })+ }+ })+ }+ }+}++func TestVMFilesystemMetadataPreservesCanonicalCompatibility(t *testing.T) {+ for name, payload := range map[string]string{+ "canonical": `{"name":"/dev/vdb1","type":"ext4","mountpoint":"/data","disk":[{"dev":"/dev/vdb1"}],"total-bytes":9000,"used-bytes":0}`,+ // JSON escapes decode to the exact canonical spelling, not an alias.+ "escaped-canonical": `{"\u006eame":"/dev/vdb1","\u0074ype":"ext4","\u006dountpoint":"/data","\u0064isk":[{"dev":"/dev/vdb1"}],"total-bytes":"9e3","used-bytes":0}`,+ "additive-metadata": `{"name":"/dev/vdb1","type":"ext4","mountpoint":"/data","disk":[{"dev":"/dev/vdb1"}],"total-bytes":9000,"used-bytes":0,"future-field":{"TYPE":"ignored"}}`,+ } {+ t.Run(name, func(t *testing.T) {+ var fs VMFileSystem+ if err := json.Unmarshal([]byte(payload), &fs); err != nil {+ t.Fatal(err)+ }+ if fs.Name != "/dev/vdb1" || fs.Type != "ext4" || fs.Mountpoint != "/data" || len(fs.DiskRaw) != 1 || fs.TotalBytes != 9000 || fs.UsedBytes != 0 {+ t.Fatalf("canonical identity or measured zero changed: %+v", fs)+ }+ })+ }+}