From f64839e2390ca7dcd31afb4a672a4c6de40ada39 Mon Sep 17 00:00:00 2001 From: Neil Wilson Date: Thu, 7 Nov 2024 15:16:45 +0000 Subject: [PATCH] Ensure refresh context doesn't get cancelled The context holding the HTTP client is used to auto refresh tokens over time. It shouldn't be cancelled. --- brightbox_auth.go | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/brightbox_auth.go b/brightbox_auth.go index 75d8771..5cc9409 100644 --- a/brightbox_auth.go +++ b/brightbox_auth.go @@ -102,11 +102,9 @@ func configureClient(ctx context.Context, authd authdetails) (CloudAccess, error // Authenticate the details and return a client func authenticatedClient(authCtx context.Context, authd authdetails) (CloudAccess, error) { klog.V(4).Infof("configureClient") - apiContext, apiCancel := context.WithCancel(context.Background()) - defer apiCancel() - apiContext = contextWithLoggedHTTPClient(apiContext) + refreshContext := contextWithLoggedHTTPClient(context.Background()) - client, err := brightbox.Connect(apiContext, confFromAuthd(authd)) + client, err := brightbox.Connect(refreshContext, confFromAuthd(authd)) if err != nil { return nil, err }