mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-09-14 13:45:06 +00:00
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
This commit is contained in:
@@ -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))
|
||||
}
|
||||
}()
|
||||
|
Reference in New Issue
Block a user