From eeed54970cdaee747be9cee3f9f496cc9d26a7ed Mon Sep 17 00:00:00 2001 From: Baptiste Girard-Carrabin Date: Wed, 29 May 2024 14:04:12 +0200 Subject: [PATCH] [main] Fix timeout on short CSI calls The same context.WithTimeout was used in different places when calling the CSI drivers. With recent changes, the code execution started taking longer and the context would hit its timeout on the 2nd driver call. This change use a separate context.WithTimeout for each CSI call --- cmd/csi-attacher/main.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/cmd/csi-attacher/main.go b/cmd/csi-attacher/main.go index 6bc8153de..0066c3526 100644 --- a/cmd/csi-attacher/main.go +++ b/cmd/csi-attacher/main.go @@ -167,7 +167,6 @@ func main() { } logger = klog.LoggerWithValues(logger, "driver", csiAttacher) logger.V(2).Info("CSI driver name") - cancelationCtx = klog.NewContext(cancelationCtx, logger) translator := csitrans.New() if translator.IsMigratedCSIDriverByName(csiAttacher) { @@ -202,6 +201,9 @@ func main() { }() } + cancelationCtx, cancel = context.WithTimeout(ctx, csiTimeout) + cancelationCtx = klog.NewContext(cancelationCtx, logger) + defer cancel() supportsService, err := supportsPluginControllerService(cancelationCtx, csiConn) if err != nil { logger.Error(err, "Failed to check if the CSI Driver supports the CONTROLLER_SERVICE")