fix: prevent cluster/resources calls on non-clustered nodes

Non-clustered Proxmox nodes were getting certificate verification errors
when Pulse tried to use the cluster/resources endpoint. Now checks if
the node is actually in a cluster before attempting efficient polling.
This commit is contained in:
Pulse Monitor
2025-08-17 20:09:45 +00:00
parent c85eebc165
commit 0629d3bbcb
2 changed files with 28 additions and 0 deletions
+14
View File
@@ -38,6 +38,7 @@ type PVEClientInterface interface {
GetVMStatus(ctx context.Context, node string, vmid int) (*proxmox.VMStatus, error)
GetContainerStatus(ctx context.Context, node string, vmid int) (*proxmox.Container, error)
GetClusterResources(ctx context.Context, resourceType string) ([]proxmox.ClusterResource, error)
IsClusterMember(ctx context.Context) (bool, error)
}
// Monitor handles all monitoring operations
@@ -855,6 +856,19 @@ func (m *Monitor) pollPVEInstance(ctx context.Context, instanceName string, clie
// pollVMsAndContainersEfficient uses the cluster/resources endpoint to get all VMs and containers in one call
func (m *Monitor) pollVMsAndContainersEfficient(ctx context.Context, instanceName string, client PVEClientInterface) bool {
// First check if this is actually a cluster member
// Non-clustered nodes will trigger certificate errors when trying to use cluster/resources
isCluster, err := client.IsClusterMember(ctx)
if err != nil {
log.Debug().Err(err).Str("instance", instanceName).Msg("Could not determine cluster membership, falling back to traditional polling")
return false
}
if !isCluster {
log.Debug().Str("instance", instanceName).Msg("Node is not in a cluster, using traditional polling")
return false
}
log.Info().Str("instance", instanceName).Msg("Polling VMs and containers using cluster/resources")
// Get all resources in a single API call
+14
View File
@@ -619,6 +619,20 @@ func (cc *ClusterClient) GetContainerStatus(ctx context.Context, node string, vm
return result, err
}
// IsClusterMember checks if this node is part of a cluster
func (cc *ClusterClient) IsClusterMember(ctx context.Context) (bool, error) {
var result bool
err := cc.executeWithFailover(ctx, func(client *Client) error {
isMember, err := client.IsClusterMember(ctx)
if err != nil {
return err
}
result = isMember
return nil
})
return result, err
}
// GetClusterHealthInfo returns detailed health information about the cluster
func (cc *ClusterClient) GetClusterHealthInfo() models.ClusterHealth {
cc.mu.RLock()