zap is used as default logger for kubebuilder-generated operators. By default, its main.go uses Development: true logging mode, meaning it will panic on logic errors such as odd number of arguments in structured logging calls (example: logger.Info("the message", "key without value argument")).
To rectify:
Set Development: false in zap options struct of main.go
If applicable: use dev mode in tests (e.g. logger := zap.New(zap.WriteTo(GinkgoWriter), zap.UseDevMode(true)))
If applicable: ensure zap is even used as controller-runtime logger (ctrl.SetLogger(zap.New(zap.UseFlagOptions(&opts)))) – we found a few spots where klogr was still used
zap is used as default logger for kubebuilder-generated operators. By default, its
main.go
usesDevelopment: true
logging mode, meaning it will panic on logic errors such as odd number of arguments in structured logging calls (example:logger.Info("the message", "key without value argument")
).To rectify:
Development: false
in zap options struct ofmain.go
logger := zap.New(zap.WriteTo(GinkgoWriter), zap.UseDevMode(true))
)ctrl.SetLogger(zap.New(zap.UseFlagOptions(&opts)))
) – we found a few spots where klogr was still usedExample PR that does all this
From a GitHub code search in the original issue of Phoenix, we found that these repos of your team are affected: