From 36a95a05eb499b0065c2d333419f4bf6b0a74d83 Mon Sep 17 00:00:00 2001 From: Patrick Ohly Date: Fri, 9 Jan 2026 11:38:06 +0100 Subject: [PATCH] ktesting: avoid increasing default verbosity Bumping to 5 is useful in unit tests. Those tend to not produce less output and ideally use per-test output, so we end up keeping only the output of failed tests where increased verbosity also in CI runs is useful. But ktesting now also gets imported into e2e test binaries through the framework. There the increased verbosity is apparently causing OOM killing in some jobs which previously worked fine. Long term we need a better solution than simply disabling the verbosity change. We could modify each unit test to call SetDefaultVerbosity, but that's tedious. Perhaps an env variable? It cannot be a command line flag because not all unit tests accept `-v`. --- pkg/kubelet/cm/dra/claiminfo_test.go | 5 +++++ pkg/kubelet/watchdog/watchdog_linux_test.go | 5 +++++ test/utils/ktesting/ktesting.go | 6 ------ 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/pkg/kubelet/cm/dra/claiminfo_test.go b/pkg/kubelet/cm/dra/claiminfo_test.go index 67f34b5ef62..71d77086278 100644 --- a/pkg/kubelet/cm/dra/claiminfo_test.go +++ b/pkg/kubelet/cm/dra/claiminfo_test.go @@ -34,6 +34,11 @@ import ( "k8s.io/kubernetes/test/utils/ktesting/initoption" ) +// Some of these tests capture log output. Don't reduce the verbosity or they will fail! +func init() { + ktesting.SetDefaultVerbosity(5) +} + // ClaimInfo test cases const ( diff --git a/pkg/kubelet/watchdog/watchdog_linux_test.go b/pkg/kubelet/watchdog/watchdog_linux_test.go index 39ab8dc6508..f45258d1909 100644 --- a/pkg/kubelet/watchdog/watchdog_linux_test.go +++ b/pkg/kubelet/watchdog/watchdog_linux_test.go @@ -29,6 +29,11 @@ import ( "k8s.io/kubernetes/test/utils/ktesting/initoption" ) +// Some of these tests capture log output. Don't reduce the verbosity or they will fail! +func init() { + ktesting.SetDefaultVerbosity(5) +} + // Mock syncLoopHealthChecker type mockSyncLoopHealthChecker struct { healthCheckErr error diff --git a/test/utils/ktesting/ktesting.go b/test/utils/ktesting/ktesting.go index fc15f809759..486a2023360 100644 --- a/test/utils/ktesting/ktesting.go +++ b/test/utils/ktesting/ktesting.go @@ -27,12 +27,6 @@ import ( _ "k8s.io/component-base/logs/testinit" ) -func init() { - // This is a good default for unit tests. Benchmarks should add their own - // init function or TestMain to lower the default, for example to 2. - SetDefaultVerbosity(5) -} - // SetDefaultVerbosity can be called during init to modify the default // log verbosity of the program. //