From 51c525a14028af98c1faaa2437542cfe489fb22d Mon Sep 17 00:00:00 2001 From: Nikita B Date: Mon, 22 Sep 2025 19:36:45 +0200 Subject: [PATCH] [126379] [go-client] chore: use WithContext functions Signed-off-by: Nikita B --- staging/src/k8s.io/client-go/rest/urlbackoff.go | 4 ++-- staging/src/k8s.io/client-go/rest/warnings.go | 7 ++----- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/staging/src/k8s.io/client-go/rest/urlbackoff.go b/staging/src/k8s.io/client-go/rest/urlbackoff.go index 5b7b4e216ef..e47b389a24b 100644 --- a/staging/src/k8s.io/client-go/rest/urlbackoff.go +++ b/staging/src/k8s.io/client-go/rest/urlbackoff.go @@ -136,7 +136,7 @@ func (b *URLBackoff) UpdateBackoffWithContext(ctx context.Context, actualURL *ur // CalculateBackoff takes a url and back's off exponentially, // based on its knowledge of existing failures. func (b *URLBackoff) CalculateBackoff(actualURL *url.URL) time.Duration { - return b.Backoff.Get(b.baseUrlKey(actualURL)) + return b.CalculateBackoffWithContext(context.Background(), actualURL) } // CalculateBackoffWithContext takes a url and back's off exponentially, @@ -146,7 +146,7 @@ func (b *URLBackoff) CalculateBackoffWithContext(ctx context.Context, actualURL } func (b *URLBackoff) Sleep(d time.Duration) { - b.Backoff.Clock.Sleep(d) + b.SleepWithContext(context.Background(), d) } func (b *URLBackoff) SleepWithContext(ctx context.Context, d time.Duration) { diff --git a/staging/src/k8s.io/client-go/rest/warnings.go b/staging/src/k8s.io/client-go/rest/warnings.go index 713b2d64d64..62bbdcee28d 100644 --- a/staging/src/k8s.io/client-go/rest/warnings.go +++ b/staging/src/k8s.io/client-go/rest/warnings.go @@ -96,11 +96,8 @@ var _ WarningHandlerWithContext = NoWarnings{} // WarningLogger is an implementation of [WarningHandler] and [WarningHandlerWithContext] that logs code 299 warnings type WarningLogger struct{} -func (WarningLogger) HandleWarningHeader(code int, agent string, message string) { - if code != 299 || len(message) == 0 { - return - } - klog.Background().Info("Warning: " + message) +func (w WarningLogger) HandleWarningHeader(code int, agent string, message string) { + w.HandleWarningHeaderWithContext(context.Background(), code, agent, message) } func (WarningLogger) HandleWarningHeaderWithContext(ctx context.Context, code int, agent string, message string) {