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.

Align the cached fallback fixture with observed recovery

pulse-triage[bot]db8587f7d103
diff --git a/pkg/proxmox/cluster_client_failover_test.go b/pkg/proxmox/cluster_client_failover_test.go
index 960e5dd9ca..51c170f6ef 100644
--- a/pkg/proxmox/cluster_client_failover_test.go
+++ b/pkg/proxmox/cluster_client_failover_test.go
@@ -7,15 +7,15 @@ import (
"time"
)
-func TestGetHealthyClientSingleEndpointFallback(t *testing.T) {
+func TestGetHealthyClientSingleEndpointFallbackKeepsObservedFailure(t *testing.T) {
endpoint := "http://example.invalid"
cc := &ClusterClient{
name: "single",
endpoints: []string{endpoint},
clients: map[string]*Client{endpoint: {}},
nodeHealth: map[string]bool{endpoint: false},
- lastError: make(map[string]string),
- lastHealthCheck: make(map[string]time.Time),
+ lastError: map[string]string{endpoint: "previous failed observation"},
+ lastHealthCheck: map[string]time.Time{endpoint: time.Now()},
rateLimitUntil: make(map[string]time.Time),
}
@@ -26,8 +26,19 @@ func TestGetHealthyClientSingleEndpointFallback(t *testing.T) {
if client == nil {
t.Fatal("expected client, got nil")
}
- if !cc.nodeHealth[endpoint] {
- t.Fatal("expected endpoint to be marked healthy after fallback")
+ if cc.nodeHealth[endpoint] || cc.lastError[endpoint] != "previous failed observation" {
+ t.Fatal("cached fallback selection must not erase an observed failure")
+ }
+ if err := cc.executeWithFailover(context.Background(), func(*Client) error {
+ return fmt.Errorf("API error 500: fixture unavailable")
+ }); err == nil || cc.nodeHealth[endpoint] {
+ t.Fatal("failed last-resort request must not establish recovery")
+ }
+ if err := cc.executeWithFailover(context.Background(), func(*Client) error { return nil }); err != nil {
+ t.Fatal(err)
+ }
+ if !cc.nodeHealth[endpoint] || cc.lastError[endpoint] != "" {
+ t.Fatal("accepted ordinary request must clear its own recorded failure")
}
}