Skip to content

armgit / Pulse

Public Imported from GitHub
0

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.

fix: Deduplicate shared storages (NFS, RBD, PBS, etc) in cluster view

rcourtman96d06da0d77d
diff --git a/internal/monitoring/monitor_polling.go b/internal/monitoring/monitor_polling.go
index 3d58f0b52d..e6a4d05fa0 100644
--- a/internal/monitoring/monitor_polling.go
+++ b/internal/monitoring/monitor_polling.go
@@ -1380,8 +1380,9 @@ func (m *Monitor) pollStorageWithNodes(ctx context.Context, instanceName string,
// Get cluster config for this storage
clusterConfig, hasClusterConfig := clusterStorageMap[storage.Storage]
- // Determine if shared
- shared := hasClusterConfig && clusterConfig.Shared == 1
+ // Determine if shared - check both the Shared flag and storage type
+ // Some storage types are inherently cluster-wide/shared even if the flag isn't set
+ shared := hasClusterConfig && (clusterConfig.Shared == 1 || isInherentlySharedStorageType(storage.Type))
// Create storage model
// Initialize Enabled/Active from per-node API response
diff --git a/internal/monitoring/storage_filters.go b/internal/monitoring/storage_filters.go
index 94beefd4c8..b55c47ccf4 100644
--- a/internal/monitoring/storage_filters.go
+++ b/internal/monitoring/storage_filters.go
@@ -6,6 +6,37 @@ import (
"github.com/rcourtman/pulse-go-rewrite/pkg/proxmox"
)
+// isInherentlySharedStorageType returns true for storage types that are inherently
+// cluster-wide/shared, even if the Proxmox API doesn't set the 'shared' flag.
+// These storage backends are designed to be accessed from multiple nodes simultaneously.
+func isInherentlySharedStorageType(storageType string) bool {
+ switch strings.ToLower(strings.TrimSpace(storageType)) {
+ case "rbd":
+ // Ceph RBD - always cluster-wide in Ceph cluster
+ return true
+ case "cephfs":
+ // CephFS - always cluster-wide
+ return true
+ case "pbs":
+ // Proxmox Backup Server - always shared/remote
+ return true
+ case "glusterfs":
+ // GlusterFS - always cluster-wide
+ return true
+ case "nfs":
+ // NFS - network shared storage, typically accessible from all nodes
+ return true
+ case "cifs", "smb":
+ // CIFS/SMB - network shared storage
+ return true
+ case "iscsi", "iscsidirect":
+ // iSCSI - can be shared across nodes
+ return true
+ default:
+ return false
+ }
+}
+
// storageContentQueryable reports whether it's safe to inspect the contents of a storage target.
// Proxmox returns storages that exist in the datacenter config even when the current node
// cannot access them. When Active==0 or the entry is disabled, querying /storage/<name>/content
diff --git a/internal/monitoring/storage_filters_test.go b/internal/monitoring/storage_filters_test.go
index a8a181f0c2..36fda01aef 100644
--- a/internal/monitoring/storage_filters_test.go
+++ b/internal/monitoring/storage_filters_test.go
@@ -6,6 +6,44 @@ import (
"github.com/rcourtman/pulse-go-rewrite/pkg/proxmox"
)
+func TestIsInherentlySharedStorageType(t *testing.T) {
+ tests := []struct {
+ name string
+ storageType string
+ want bool
+ }{
+ {"rbd is shared", "rbd", true},
+ {"RBD uppercase is shared", "RBD", true},
+ {"cephfs is shared", "cephfs", true},
+ {"pbs is shared", "pbs", true},
+ {"PBS uppercase is shared", "PBS", true},
+ {"glusterfs is shared", "glusterfs", true},
+ {"nfs is shared", "nfs", true},
+ {"NFS uppercase is shared", "NFS", true},
+ {"cifs is shared", "cifs", true},
+ {"smb is shared", "smb", true},
+ {"iscsi is shared", "iscsi", true},
+ {"iscsidirect is shared", "iscsidirect", true},
+ {"dir is not shared", "dir", false},
+ {"lvm is not shared", "lvm", false},
+ {"lvmthin is not shared", "lvmthin", false},
+ {"zfspool is not shared", "zfspool", false},
+ {"zfs is not shared", "zfs", false},
+ {"local is not shared", "local", false},
+ {"empty string is not shared", "", false},
+ {"whitespace is not shared", " ", false},
+ {"rbd with spaces is shared", " rbd ", true},
+ }
+
+ for _, tt := range tests {
+ t.Run(tt.name, func(t *testing.T) {
+ if got := isInherentlySharedStorageType(tt.storageType); got != tt.want {
+ t.Errorf("isInherentlySharedStorageType(%q) = %v, want %v", tt.storageType, got, tt.want)
+ }
+ })
+ }
+}
+
func TestStorageContentQueryable(t *testing.T) {
tests := []struct {
name string