Prefer IP addresses over hostnames for cluster communication

This change modifies the `clusterEndpointEffectiveURL` function to prioritize
IP addresses over hostnames when building cluster endpoint URLs. This eliminates
excessive DNS lookups that can overwhelm DNS servers (e.g., pi-hole), which was
causing hundreds of thousands of unnecessary DNS queries.

When Pulse communicates with Proxmox cluster nodes, it will now:
1. First try to use the IP address from ClusterEndpoint.IP
2. Fall back to ClusterEndpoint.Host only if IP is not available

This is a minimal, backwards-compatible change that maintains existing
functionality while dramatically reducing DNS traffic for clusters where
node IPs are already known and stored.

Related to #620
This commit is contained in:
rcourtman 2025-11-05 19:23:26 +00:00
parent f0088070be
commit 350828a260

View file

@ -281,12 +281,13 @@ func ensureClusterEndpointURL(raw string) string {
}
func clusterEndpointEffectiveURL(endpoint config.ClusterEndpoint) string {
if endpoint.Host != "" {
return ensureClusterEndpointURL(endpoint.Host)
}
// Prefer IP address to avoid excessive DNS lookups
if endpoint.IP != "" {
return ensureClusterEndpointURL(endpoint.IP)
}
if endpoint.Host != "" {
return ensureClusterEndpointURL(endpoint.Host)
}
return ""
}