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.

Record VMware provider build failures

rcourtman4c4d433666b1
diff --git a/internal/monitoring/vmware_poller.go b/internal/monitoring/vmware_poller.go
index 5fd4edab5a..3e912e0983 100644
--- a/internal/monitoring/vmware_poller.go
+++ b/internal/monitoring/vmware_poller.go
@@ -325,6 +325,8 @@ func (p *VMwarePoller) syncConnections() {
provider, err := p.newProvider(instance)
if err != nil {
+ at := time.Now().UTC()
+ p.recordConnectionFailureLocked(orgID, connectionID, err, at)
log.Warn().
Str("component", "vmware_poller").
Str("action", "build_provider").
@@ -368,7 +370,7 @@ func (p *VMwarePoller) syncConnections() {
}
}
- if len(providers) == 0 {
+ if len(providers) == 0 && len(activeConnections) == 0 {
delete(p.providersByOrg, orgID)
delete(p.configsByOrg, orgID)
delete(p.statusByOrg, orgID)
diff --git a/internal/monitoring/vmware_poller_test.go b/internal/monitoring/vmware_poller_test.go
index 1296f58923..1f768f54f1 100644
--- a/internal/monitoring/vmware_poller_test.go
+++ b/internal/monitoring/vmware_poller_test.go
@@ -225,6 +225,44 @@ func TestVMwarePollerConnectionSummariesCaptureFailuresWithoutClearingObservedSu
}
}
+func TestVMwarePollerSyncRecordsProviderConstructionFailure(t *testing.T) {
+ mtp, persistence := newTestTenantPersistence(t)
+ connection := config.NewVMwareVCenterInstance()
+ connection.ID = "vc-build-fail"
+ connection.Host = "vc.build-fail.local"
+ connection.Username = "[email protected]"
+ connection.Password = "secret"
+ if err := persistence.SaveVMwareConfig([]config.VMwareVCenterInstance{connection}); err != nil {
+ t.Fatalf("SaveVMwareConfig() error = %v", err)
+ }
+
+ poller := NewVMwarePoller(mtp, time.Minute)
+ poller.newProvider = func(config.VMwareVCenterInstance) (vmwarePollerProvider, error) {
+ return nil, &vmware.ConnectionError{
+ Category: "auth",
+ Message: "VMware credentials were rejected",
+ }
+ }
+
+ poller.syncConnections()
+ poller.syncConnections()
+
+ if providers := poller.providersByOrg["default"]; len(providers) != 0 {
+ t.Fatalf("expected provider construction failure to leave no providers, got %d", len(providers))
+ }
+
+ summary := poller.ConnectionSummaries("default", []config.VMwareVCenterInstance{connection})[connection.ID]
+ if summary.Poll == nil || summary.Poll.LastAttemptAt == nil || summary.Poll.LastError == nil {
+ t.Fatalf("expected provider construction failure in poll summary, got %+v", summary.Poll)
+ }
+ if summary.Poll.ConsecutiveFailures != 2 {
+ t.Fatalf("consecutive failures = %d, want 2", summary.Poll.ConsecutiveFailures)
+ }
+ if summary.Poll.LastError.Category != "auth" || !strings.Contains(summary.Poll.LastError.Message, "credentials were rejected") {
+ t.Fatalf("unexpected provider construction error summary: %+v", summary.Poll.LastError)
+ }
+}
+
type failingVMwarePollerProvider struct {
err error
}