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(diagnostics): honor PVE fingerprint in diagnostics probe

rcourtman1a582ccc3552
diff --git a/internal/api/diagnostics.go b/internal/api/diagnostics.go
index f577de49b0..420f584898 100644
--- a/internal/api/diagnostics.go
+++ b/internal/api/diagnostics.go
@@ -480,6 +480,7 @@ func (r *Router) computeDiagnostics(ctx context.Context) DiagnosticsInfo {
Password: node.Password,
TokenName: node.TokenName,
TokenValue: node.TokenValue,
+ Fingerprint: node.Fingerprint,
VerifySSL: node.VerifySSL,
}
diff --git a/internal/api/diagnostics_additional_test.go b/internal/api/diagnostics_additional_test.go
index 7e7ae0ff9f..8a5ca3a67a 100644
--- a/internal/api/diagnostics_additional_test.go
+++ b/internal/api/diagnostics_additional_test.go
@@ -13,6 +13,7 @@ import (
"github.com/rcourtman/pulse-go-rewrite/internal/monitoring"
agentsdocker "github.com/rcourtman/pulse-go-rewrite/pkg/agents/docker"
"github.com/rcourtman/pulse-go-rewrite/pkg/proxmox"
+ "github.com/rcourtman/pulse-go-rewrite/pkg/tlsutil"
)
type stubAIPersistence struct {
@@ -154,6 +155,61 @@ func TestComputeDiagnostics_Basic(t *testing.T) {
}
}
+func TestComputeDiagnostics_PVEUsesFingerprint(t *testing.T) {
+ server := httptest.NewTLSServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
+ w.Header().Set("Content-Type", "application/json")
+
+ switch r.URL.Path {
+ case "/api2/json/nodes":
+ _, _ = w.Write([]byte(`{"data":[{"node":"pve1","status":"online"}]}`))
+ case "/api2/json/nodes/pve1/status":
+ _, _ = w.Write([]byte(`{"data":{"pveversion":"pve-manager/8.4.1"}}`))
+ case "/api2/json/cluster/status":
+ _, _ = w.Write([]byte(`{"data":[{"type":"cluster"},{"type":"node"}]}`))
+ case "/api2/json/nodes/pve1/qemu":
+ _, _ = w.Write([]byte(`{"data":[]}`))
+ case "/api2/json/nodes/pve1/disks/list":
+ _, _ = w.Write([]byte(`{"data":[]}`))
+ default:
+ http.NotFound(w, r)
+ }
+ }))
+ defer server.Close()
+
+ fingerprint, err := tlsutil.FetchFingerprint(server.URL)
+ if err != nil {
+ t.Fatalf("FetchFingerprint: %v", err)
+ }
+
+ cfg := &config.Config{
+ DataPath: t.TempDir(),
+ PVEInstances: []config.PVEInstance{
+ {
+ Name: "pve1",
+ Host: server.URL,
+ TokenName: "user@pam!token",
+ TokenValue: "secret",
+ VerifySSL: true,
+ Fingerprint: fingerprint,
+ },
+ },
+ }
+ monitor := newMonitorForDiagnostics(t, cfg)
+
+ router := &Router{config: cfg, monitor: monitor}
+ diag := router.computeDiagnostics(context.Background())
+
+ if len(diag.Nodes) != 1 {
+ t.Fatalf("node count = %d, want 1", len(diag.Nodes))
+ }
+ if !diag.Nodes[0].Connected {
+ t.Fatalf("expected fingerprint-pinned PVE diagnostics probe to succeed, got error: %q", diag.Nodes[0].Error)
+ }
+ if diag.Nodes[0].Error != "" {
+ t.Fatalf("unexpected diagnostics error: %q", diag.Nodes[0].Error)
+ }
+}
+
func TestBuildAPITokenDiagnostic_WithDockerUsage(t *testing.T) {
now := time.Now()
lastUsed := now.Add(-time.Hour)