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: support ReportIP override in Proxmox auto-registration (#1061)

rcourtman5f0214b9490b
diff --git a/internal/hostagent/agent.go b/internal/hostagent/agent.go
index 6afa4c478f..2e975a726a 100644
--- a/internal/hostagent/agent.go
+++ b/internal/hostagent/agent.go
@@ -797,6 +797,7 @@ func (a *Agent) runProxmoxSetup(ctx context.Context) {
a.cfg.APIToken,
a.cfg.ProxmoxType,
a.hostname,
+ a.reportIP,
a.cfg.InsecureSkipVerify,
)
diff --git a/internal/hostagent/proxmox_setup.go b/internal/hostagent/proxmox_setup.go
index e5203682b7..3042fb1016 100644
--- a/internal/hostagent/proxmox_setup.go
+++ b/internal/hostagent/proxmox_setup.go
@@ -25,6 +25,7 @@ type ProxmoxSetup struct {
apiToken string
proxmoxType string // "pve", "pbs", or "" for auto-detect
hostname string
+ reportIP string
insecureSkipVerify bool
}
@@ -50,7 +51,7 @@ const (
)
// NewProxmoxSetup creates a new ProxmoxSetup instance.
-func NewProxmoxSetup(logger zerolog.Logger, httpClient *http.Client, pulseURL, apiToken, proxmoxType, hostname string, insecure bool) *ProxmoxSetup {
+func NewProxmoxSetup(logger zerolog.Logger, httpClient *http.Client, pulseURL, apiToken, proxmoxType, hostname, reportIP string, insecure bool) *ProxmoxSetup {
return &ProxmoxSetup{
logger: logger,
httpClient: httpClient,
@@ -58,6 +59,7 @@ func NewProxmoxSetup(logger zerolog.Logger, httpClient *http.Client, pulseURL, a
apiToken: apiToken,
proxmoxType: proxmoxType,
hostname: hostname,
+ reportIP: reportIP,
insecureSkipVerify: insecure,
}
}
@@ -358,7 +360,15 @@ func (p *ProxmoxSetup) getHostURL(ptype string) string {
port = "8007"
}
- // First, try to determine which local IP is used to connect to Pulse
+ // Priority 1: User-specified ReportIP override from configuration.
+ // This allows users to manually specify which IP should be used for Proxmox API
+ // connections when auto-detection picks the wrong one (e.g., Issue #1061).
+ if p.reportIP != "" {
+ p.logger.Info().Str("ip", p.reportIP).Msg("Using user-specified ReportIP for Proxmox registration")
+ return fmt.Sprintf("https://%s:%s", p.reportIP, port)
+ }
+
+ // Priority 2: Try to determine which local IP is used to connect to Pulse
// This ensures we pick an IP that can actually communicate with the Pulse server
if reachableIP := p.getIPThatReachesPulse(); reachableIP != "" {
p.logger.Debug().Str("ip", reachableIP).Msg("Using IP that can reach Pulse server")
diff --git a/internal/hostagent/proxmox_setup_test.go b/internal/hostagent/proxmox_setup_test.go
index 8137158af5..b273ae0068 100644
--- a/internal/hostagent/proxmox_setup_test.go
+++ b/internal/hostagent/proxmox_setup_test.go
@@ -1,6 +1,10 @@
package hostagent
-import "testing"
+import (
+ "testing"
+
+ "github.com/rs/zerolog"
+)
func TestSelectBestIP(t *testing.T) {
tests := []struct {
@@ -154,3 +158,37 @@ func TestStateFileForType(t *testing.T) {
})
}
}
+func TestGetHostURL(t *testing.T) {
+ tests := []struct {
+ name string
+ ptype string
+ reportIP string
+ expected string
+ }{
+ {
+ name: "uses reportIP override for PVE",
+ ptype: "pve",
+ reportIP: "10.0.0.50",
+ expected: "https://10.0.0.50:8006",
+ },
+ {
+ name: "uses reportIP override for PBS",
+ ptype: "pbs",
+ reportIP: "192.168.1.100",
+ expected: "https://192.168.1.100:8007",
+ },
+ }
+
+ for _, tt := range tests {
+ t.Run(tt.name, func(t *testing.T) {
+ setup := &ProxmoxSetup{
+ reportIP: tt.reportIP,
+ logger: zerolog.Nop(),
+ }
+ result := setup.getHostURL(tt.ptype)
+ if result != tt.expected {
+ t.Errorf("getHostURL(%q) = %q, want %q", tt.ptype, result, tt.expected)
+ }
+ })
+ }
+}