From 4526b28606c99ea569fa66fe278c00b0eb932509 Mon Sep 17 00:00:00 2001 From: Patrick Ohly Date: Wed, 16 Oct 2024 10:46:24 +0200 Subject: [PATCH] ktesting: improve context message This is not necessarily a problem, some code might use a timeout and expect it to trigger. Therefore this should only be an info message, not a warning. Long-term it might be useful to have an API where the caller decides whether this gets logged. The caller should use short messages and leave it to the user of those to provide more context (no pun intended...). When logging, "canceling context" is that context. Before: scheduler_perf.go:1431: FATAL ERROR: op 7: delete scheduled pods: client rate limiter Wait returned an error: rate: Wait(n=1) would exceed context deadline contexthelper.go:69: WARNING: the operation ran for the configured 2s After: scheduler_perf.go:1431: FATAL ERROR: op 7: delete scheduled pods: client rate limiter Wait returned an error: rate: Wait(n=1) would exceed context deadline contexthelper.go:69: INFO: canceling context: the operation ran for the configured 2s --- test/utils/ktesting/contexthelper.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/utils/ktesting/contexthelper.go b/test/utils/ktesting/contexthelper.go index bcfdd4d284e..57055d17589 100644 --- a/test/utils/ktesting/contexthelper.go +++ b/test/utils/ktesting/contexthelper.go @@ -66,7 +66,7 @@ func withTimeout(ctx context.Context, tb TB, timeout time.Duration, timeoutCause // // Would be nice to log this with the source code location // of our caller, but testing.Logf does not support that. - tb.Logf("\nWARNING: %s\n", timeoutCause) + tb.Logf("\nINFO: canceling context: %s\n", timeoutCause) cancel(canceledError(timeoutCause)) } }()