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(monitor): use cluster quorum status instead of endpoint count for health

rcourtman80444a9022d9
diff --git a/internal/monitoring/monitor.go b/internal/monitoring/monitor.go
index 8dc3dc351b..fbd976449d 100644
--- a/internal/monitoring/monitor.go
+++ b/internal/monitoring/monitor.go
@@ -5538,14 +5538,38 @@ func (m *Monitor) pollPVEInstance(ctx context.Context, instanceName string, clie
connectionHealthStr = "error"
m.state.SetConnectionHealth(instanceName, false)
} else if healthyCount < totalCount {
- // Some endpoints are down - degraded state
- connectionHealthStr = "degraded"
- m.state.SetConnectionHealth(instanceName, true) // Still functional but degraded
- log.Warn().
- Str("instance", instanceName).
- Int("healthy", healthyCount).
- Int("total", totalCount).
- Msg("Cluster is in degraded state - some nodes are unreachable")
+ // Some endpoints are down - check if cluster still has quorum
+ // A cluster with quorum is healthy even if some nodes are intentionally offline
+ // (e.g., backup nodes not running). Only mark as degraded if no quorum.
+ isQuorate, err := clusterClient.IsQuorate(ctx)
+ if err != nil {
+ // Couldn't check quorum - log but continue (assume healthy if we have connectivity)
+ log.Debug().
+ Str("instance", instanceName).
+ Err(err).
+ Msg("Could not check cluster quorum status")
+ isQuorate = true // Assume healthy if we can't check
+ }
+
+ if isQuorate {
+ // Cluster has quorum - healthy even with some nodes offline
+ connectionHealthStr = "healthy"
+ m.state.SetConnectionHealth(instanceName, true)
+ log.Debug().
+ Str("instance", instanceName).
+ Int("healthy", healthyCount).
+ Int("total", totalCount).
+ Msg("Cluster has quorum - some API endpoints unreachable but cluster is healthy")
+ } else {
+ // Cluster lost quorum - this is actually degraded/critical
+ connectionHealthStr = "degraded"
+ m.state.SetConnectionHealth(instanceName, true) // Still functional but degraded
+ log.Warn().
+ Str("instance", instanceName).
+ Int("healthy", healthyCount).
+ Int("total", totalCount).
+ Msg("Cluster lost quorum - degraded state")
+ }
} else {
// All endpoints are healthy
connectionHealthStr = "healthy"
diff --git a/pkg/proxmox/cluster_client.go b/pkg/proxmox/cluster_client.go
index 908e5cd833..001ec39ae2 100644
--- a/pkg/proxmox/cluster_client.go
+++ b/pkg/proxmox/cluster_client.go
@@ -1360,6 +1360,42 @@ func (cc *ClusterClient) GetDisks(ctx context.Context, node string) ([]Disk, err
return result, err
}
+// GetClusterStatus returns the cluster status including all nodes with failover support.
+func (cc *ClusterClient) GetClusterStatus(ctx context.Context) ([]ClusterStatus, error) {
+ var result []ClusterStatus
+ err := cc.executeWithFailover(ctx, func(client *Client) error {
+ status, err := client.GetClusterStatus(ctx)
+ if err != nil {
+ return err
+ }
+ result = status
+ return nil
+ })
+
+ return result, err
+}
+
+// IsQuorate checks if the cluster has quorum by querying the Proxmox cluster status.
+// Returns true if the cluster is quorate (has enough votes for consensus), false otherwise.
+// This is the authoritative check for cluster health - a cluster with quorum is healthy
+// even if some nodes are intentionally offline (e.g., backup nodes not running).
+func (cc *ClusterClient) IsQuorate(ctx context.Context) (bool, error) {
+ status, err := cc.GetClusterStatus(ctx)
+ if err != nil {
+ return false, err
+ }
+
+ // Look for the cluster entry which has the quorate field
+ for _, s := range status {
+ if s.Type == "cluster" {
+ return s.Quorate == 1, nil
+ }
+ }
+
+ // If no cluster entry found, this might be a standalone node - consider it healthy
+ return true, nil
+}
+
// isAuthError checks if an error is an authentication error
func isAuthError(err error) bool {
if err == nil {