From d17aaf5e29f209ca71047078650e9dcd266e47a4 Mon Sep 17 00:00:00 2001 From: Patrick Ohly Date: Wed, 10 Dec 2025 16:00:33 +0100 Subject: [PATCH] e2e: suppress or ignore init log output klog calls during init are becoming a problem because now test/e2e/framework depends in test/utils/ktesting which bumps up the default verbosity during init to make test output more complete when there is no argument parsing. For cadvisor, an upstream fix is needed (https://github.com/google/cadvisor/pull/3778). For kubectl we can make it silently accept the valid (!) LC_ALL=C. --- hack/verify-e2e-images.sh | 11 +++++++++-- staging/src/k8s.io/kubectl/pkg/util/i18n/i18n.go | 4 +++- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/hack/verify-e2e-images.sh b/hack/verify-e2e-images.sh index 7c99a73d727..db684e60d5a 100755 --- a/hack/verify-e2e-images.sh +++ b/hack/verify-e2e-images.sh @@ -24,6 +24,10 @@ cd "${KUBE_ROOT}" source hack/lib/init.sh ret=0 +# We need deterministic sort order and want to avoid this extra log output: +# i18n.go:119] Couldn't find the LC_ALL, LC_MESSAGES or LANG environment variables, defaulting to en_US +export LC_ALL=C + # NOTE: Please do NOT add any to this list!! # # We are aiming to consolidate on: registry.k8s.io/e2e-test-images/agnhost @@ -39,7 +43,10 @@ e2e_test="$(kube::util::find-binary e2e.test)" # validate "e2e.test --list-images": # - no unexpected output (whether it's on stderr or stdout) # - zero exit code (indirectly ensures that tests are set up properly) -output=$("${e2e_test}" --list-images 2>&1) || ret=$? +# +# For now (https://github.com/google/cadvisor/issues/3707, https://github.com/google/cadvisor/pull/3778) +# we have to ignore additional output caused by cadvisor. +output=$("${e2e_test}" --list-images 2>&1 | grep -v 'factory.go.*Registered Plugin' ) || ret=$? if [[ $ret -ne 0 ]]; then >&2 echo "FAIL: '${e2e_test} --list-images' failed:" >&2 echo "${output}" @@ -54,7 +61,7 @@ if [[ -n "${unexpected_output}" ]]; then fi # extract image names without the version -kube::util::read-array IMAGES < <(echo "${output}" | sed -E 's/^([[:alnum:]/.-]+):[^:]+$/\1/' | LC_ALL=C sort -u) +kube::util::read-array IMAGES < <(echo "${output}" | sed -E 's/^([[:alnum:]/.-]+):[^:]+$/\1/' | sort -u) # diff versus known permitted images >&2 echo "Diffing e2e image list ..." diff --git a/staging/src/k8s.io/kubectl/pkg/util/i18n/i18n.go b/staging/src/k8s.io/kubectl/pkg/util/i18n/i18n.go index 8b8481c7bd3..327230dda08 100644 --- a/staging/src/k8s.io/kubectl/pkg/util/i18n/i18n.go +++ b/staging/src/k8s.io/kubectl/pkg/util/i18n/i18n.go @@ -121,7 +121,9 @@ func loadSystemLanguage() string { } pieces := strings.Split(langStr, ".") if len(pieces) != 2 { - klog.V(3).Infof("Unexpected system language (%s), defaulting to en_US", langStr) + if langStr != "C" { + klog.V(3).Infof("Unexpected system language (%s), defaulting to en_US", langStr) + } return "default" } return pieces[0]