From 43c48b21132f3a4f088670fac82fe7a3d0bcaf19 Mon Sep 17 00:00:00 2001 From: Patrick Ohly Date: Sat, 17 Dec 2022 05:09:19 +0000 Subject: [PATCH] enhance and fix log calls Some of these changes are cosmetic (repeatedly calling klog.V instead of reusing the result), others address real issues: - Logging a message only above a certain verbosity threshold without recording that verbosity level (if klog.V().Enabled() { klog.Info... }): this matters when using a logging backend which records the verbosity level. - Passing a format string with parameters to a logging function that doesn't do string formatting. All of these locations where found by the enhanced logcheck tool from https://github.com/kubernetes/klog/pull/297. In some cases it reports false positives, but those can be suppressed with source code comments. Partial cherry-pick of edffc700a43e610f641907290a5152ca593bad79 Kubernetes-commit: 4da1f79f991f52f69dbb9d567bdd4f5e1d7b0b24 --- pkg/registry/generic/registry/storage_factory.go | 1 + 1 file changed, 1 insertion(+) diff --git a/pkg/registry/generic/registry/storage_factory.go b/pkg/registry/generic/registry/storage_factory.go index 6a4426ee6..0d1c00c00 100644 --- a/pkg/registry/generic/registry/storage_factory.go +++ b/pkg/registry/generic/registry/storage_factory.go @@ -50,6 +50,7 @@ func StorageWithCacher() generic.StorageDecorator { return s, d, err } if klog.V(5).Enabled() { + //nolint:logcheck // It complains about the key/value pairs because it cannot check them. klog.InfoS("Storage caching is enabled", objectTypeToArgs(newFunc())...) }