-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Description
The following log output is redundant and potentially confusing:
Lines 189 to 195 in 5adb1c3
func RegisterPlugin(name string, plugin Plugin) error { | |
pluginsLock.Lock() | |
defer pluginsLock.Unlock() | |
if _, found := plugins[name]; found { | |
return fmt.Errorf("Plugin %q was registered twice", name) | |
} | |
klog.V(4).Infof("Registered Plugin %q", name) |
RegisterPlugin
gets called during init, for example in
err := container.RegisterPlugin("containerd", containerd.NewPlugin()) |
During init, klog verbosity is either zero (making the log call redundant because it doesn't print anything) or some other init function reconfigures logging, in which case the output is potentially confusing because it is not guaranteed that logging is reconfigured before the plugin install functions.
I ran into this when experimenting with the logging configuration in the Kubernetes test/e2e suite. I got log output for "containerd", but not for "systemd" and "crio", although those were also registered in the process (confirmed in a debugger).
In other scenarios, flag parsing might switch from klog text format to something else entirely, which then leads to a mixture of text and e.g. JSON output. In general, code running during init should not log.