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 temperature data intermittency caused by proxy rate limit retries

rcourtmane4e915c8a1f7
diff --git a/internal/monitoring/monitor.go b/internal/monitoring/monitor.go
index a1eacefefd..b23eafb56d 100644
--- a/internal/monitoring/monitor.go
+++ b/internal/monitoring/monitor.go
@@ -7523,6 +7523,20 @@ func (m *Monitor) StopDiscoveryService() {
}
}
+// EnableTemperatureMonitoring enables temperature data collection
+func (m *Monitor) EnableTemperatureMonitoring() {
+ // Temperature collection is always enabled when tempCollector is initialized
+ // This method exists for interface compatibility
+ log.Info().Msg("Temperature monitoring enabled")
+}
+
+// DisableTemperatureMonitoring disables temperature data collection
+func (m *Monitor) DisableTemperatureMonitoring() {
+ // Temperature collection is always enabled when tempCollector is initialized
+ // This method exists for interface compatibility
+ log.Info().Msg("Temperature monitoring disabled")
+}
+
// GetGuestMetrics returns historical metrics for a guest
func (m *Monitor) GetGuestMetrics(guestID string, duration time.Duration) map[string][]MetricPoint {
return m.metricsHistory.GetAllGuestMetrics(guestID, duration)
diff --git a/internal/tempproxy/client.go b/internal/tempproxy/client.go
index 7bd87d8d6c..958f289299 100644
--- a/internal/tempproxy/client.go
+++ b/internal/tempproxy/client.go
@@ -122,32 +122,20 @@ func calculateBackoff(attempt int) time.Duration {
// classifyError categorizes errors for retry logic
func classifyError(err error, respError string) *ProxyError {
- if err == nil {
- return nil
- }
-
- // Check for timeout
- if netErr, ok := err.(net.Error); ok && netErr.Timeout() {
- return &ProxyError{
- Type: ErrorTypeTimeout,
- Message: "operation timed out",
- Retryable: true,
- Wrapped: err,
+ // Check response error messages first (even if err is nil)
+ // This handles cases where the socket succeeds but the proxy returns an application error
+ if respError != "" {
+ // Rate limiting - never retry
+ if contains(respError, "rate limit") {
+ return &ProxyError{
+ Type: ErrorTypeTransport,
+ Message: respError,
+ Retryable: false,
+ Wrapped: fmt.Errorf("%s", respError),
+ }
}
- }
- // Check for connection errors (socket unavailable)
- if _, ok := err.(*net.OpError); ok {
- return &ProxyError{
- Type: ErrorTypeTransport,
- Message: "failed to connect to proxy socket",
- Retryable: true,
- Wrapped: err,
- }
- }
-
- // Check response error messages
- if respError != "" {
+ // Authorization errors - never retry
if respError == "unauthorized" || respError == "method requires host-level privileges" {
return &ProxyError{
Type: ErrorTypeAuth,
@@ -157,7 +145,7 @@ func classifyError(err error, respError string) *ProxyError {
}
}
- // SSH-related errors
+ // SSH-related errors - retryable
if contains(respError, "ssh", "connection", "timeout") {
return &ProxyError{
Type: ErrorTypeSSH,
@@ -167,7 +155,7 @@ func classifyError(err error, respError string) *ProxyError {
}
}
- // Sensor errors
+ // Sensor errors - never retry
if contains(respError, "sensor", "temperature") {
return &ProxyError{
Type: ErrorTypeSensor,
@@ -178,6 +166,31 @@ func classifyError(err error, respError string) *ProxyError {
}
}
+ // If no response error and no network error, nothing to classify
+ if err == nil {
+ return nil
+ }
+
+ // Check for timeout
+ if netErr, ok := err.(net.Error); ok && netErr.Timeout() {
+ return &ProxyError{
+ Type: ErrorTypeTimeout,
+ Message: "operation timed out",
+ Retryable: true,
+ Wrapped: err,
+ }
+ }
+
+ // Check for connection errors (socket unavailable)
+ if _, ok := err.(*net.OpError); ok {
+ return &ProxyError{
+ Type: ErrorTypeTransport,
+ Message: "failed to connect to proxy socket",
+ Retryable: true,
+ Wrapped: err,
+ }
+ }
+
// Unknown error
return &ProxyError{
Type: ErrorTypeUnknown,