From af7eabb56d24752131fe037e23ccc67f8be6bea6 Mon Sep 17 00:00:00 2001 From: "courtmanr@gmail.com" Date: Sun, 23 Nov 2025 22:28:28 +0000 Subject: [PATCH] Fix: Correct context cancellation in loop (Fixes #727) - Replaced defer in loop with explicit cancellation to avoid resource leak - Properly tagged issue #727 --- internal/monitoring/monitor.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/monitoring/monitor.go b/internal/monitoring/monitor.go index c39dcf0..a2fdf9b 100644 --- a/internal/monitoring/monitor.go +++ b/internal/monitoring/monitor.go @@ -6160,7 +6160,6 @@ func (m *Monitor) pollPVEInstance(ctx context.Context, instanceName string, clie } if effectiveStatus == "online" && m.tempCollector != nil && tempMonitoringEnabled { tempCtx, tempCancel := context.WithTimeout(ctx, 30*time.Second) // Increased to accommodate SSH operations via proxy - defer tempCancel() // Determine SSH hostname to use (most robust approach): // Prefer the resolved host for this node, with cluster overrides when available. @@ -6200,6 +6199,7 @@ func (m *Monitor) pollPVEInstance(ctx context.Context, instanceName string, clie // Use HTTP proxy if configured for this instance, otherwise fall back to socket/SSH temp, err := m.tempCollector.CollectTemperatureWithProxy(tempCtx, sshHost, node.Node, instanceCfg.TemperatureProxyURL, instanceCfg.TemperatureProxyToken) + tempCancel() if err == nil && temp != nil && temp.Available { // Get the current CPU temperature (prefer package, fall back to max)