From 6a29e20b5eeed4c7754aa6b00b6115d45f6f3c5d Mon Sep 17 00:00:00 2001 From: rcourtman Date: Tue, 2 Dec 2025 15:39:37 +0000 Subject: [PATCH] perf: Cache err.Error() in storage timeout error handling Cache err.Error() result in two locations: - monitor.go: storage query retry logic (2x calls to 1) - monitor_polling.go: storage timeout handling (2x calls to 1) --- internal/monitoring/monitor.go | 3 ++- internal/monitoring/monitor_polling.go | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/internal/monitoring/monitor.go b/internal/monitoring/monitor.go index f944be9..05bb3a2 100644 --- a/internal/monitoring/monitor.go +++ b/internal/monitoring/monitor.go @@ -6968,7 +6968,8 @@ func (m *Monitor) pollStorageBackupsWithNodes(ctx context.Context, instanceName } // Check if it's a timeout error - if strings.Contains(err.Error(), "timeout") || strings.Contains(err.Error(), "deadline exceeded") { + errStr := err.Error() + if strings.Contains(errStr, "timeout") || strings.Contains(errStr, "deadline exceeded") { if attempt == 1 { log.Warn(). Str("node", node.Node). diff --git a/internal/monitoring/monitor_polling.go b/internal/monitoring/monitor_polling.go index 9828cba..51f2b22 100644 --- a/internal/monitoring/monitor_polling.go +++ b/internal/monitoring/monitor_polling.go @@ -1231,7 +1231,8 @@ func (m *Monitor) pollStorageWithNodes(ctx context.Context, instanceName string, } if err != nil { // Handle timeout gracefully - unavailable storage (e.g., NFS mounts) can cause this - if strings.Contains(err.Error(), "timeout") || strings.Contains(err.Error(), "deadline exceeded") { + errStr := err.Error() + if strings.Contains(errStr, "timeout") || strings.Contains(errStr, "deadline exceeded") { log.Warn(). Str("node", n.Node). Str("instance", instanceName).