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 Ceph clusters by FSID before sending to frontend

rcourtmaneff4adda4950
diff --git a/internal/models/state_snapshot.go b/internal/models/state_snapshot.go
index eed758830e..c777c50844 100644
--- a/internal/models/state_snapshot.go
+++ b/internal/models/state_snapshot.go
@@ -138,10 +138,29 @@ func (s StateSnapshot) ToFrontend() StateFrontend {
storage[i] = st.ToFrontend()
}
- // Convert Ceph clusters
- cephClusters := make([]CephClusterFrontend, len(s.CephClusters))
- for i, cluster := range s.CephClusters {
- cephClusters[i] = cluster.ToFrontend()
+ // Convert Ceph clusters - deduplicate by FSID (same cluster may be reported from multiple sources)
+ // When PVE and host agent both report the same Ceph cluster, prefer the one with more data
+ cephByFSID := make(map[string]CephCluster)
+ for _, cluster := range s.CephClusters {
+ fsid := cluster.FSID
+ if fsid == "" {
+ fsid = cluster.ID // fallback for clusters without FSID
+ }
+ existing, exists := cephByFSID[fsid]
+ if !exists {
+ cephByFSID[fsid] = cluster
+ continue
+ }
+ // Keep the cluster with more complete data (more monitors/managers/pools reported)
+ existingScore := existing.NumMons + existing.NumMgrs + len(existing.Pools)
+ newScore := cluster.NumMons + cluster.NumMgrs + len(cluster.Pools)
+ if newScore > existingScore {
+ cephByFSID[fsid] = cluster
+ }
+ }
+ cephClusters := make([]CephClusterFrontend, 0, len(cephByFSID))
+ for _, cluster := range cephByFSID {
+ cephClusters = append(cephClusters, cluster.ToFrontend())
}
replicationJobs := make([]ReplicationJobFrontend, len(s.ReplicationJobs))