-
Notifications
You must be signed in to change notification settings - Fork 371
fix(controller): ensure log level is respected #1135
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Signed-off-by: Brian Fox <878612+onematchfox@users.noreply.github.com>
Signed-off-by: Brian Fox <878612+onematchfox@users.noreply.github.com>
Signed-off-by: Brian Fox <878612+onematchfox@users.noreply.github.com>
Signed-off-by: Brian Fox <878612+onematchfox@users.noreply.github.com>
| utilruntime.Must(v1alpha2.AddToScheme(scheme)) | ||
| // +kubebuilder:scaffold:scheme | ||
|
|
||
| ctrl.SetLogger(zap.New(zap.UseDevMode(true))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was introduced in 2cb72c3 - although I can't see any reason why it's needed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR fixes the controller's log level configuration to properly respect the -zap-log-level flag by removing the hardcoded Development: true setting from zap.Options. Previously, development mode enabled V(1) verbosity logs by default regardless of the specified log level, causing DEBUG-level logs to always appear in production.
Key changes:
- Removed unused
LOG_LEVELenvironment variable from the Helm deployment template - Removed
Development: truefrom zap logger configuration to respect the-zap-log-levelflag - Consolidated duplicate startup logging statements into a single log entry
- Added explicit
--set controller.loglevel=debugto local development Makefile target
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
helm/kagent/templates/controller-deployment.yaml |
Removed unused LOG_LEVEL environment variable that was never consumed by the application |
go/pkg/app/app.go |
Removed Development mode default, eliminated duplicate logger initialization in init(), and consolidated startup logging |
Makefile |
Added explicit debug log level configuration for local development environment |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This PR ensures that the log level specified when installing kagent is respected by the controller. Currently this is not respected because when
Development: trueis set, controller-runtime's zap logger enables verbosity level (V(1)) logs by default, which get logged aslog.V(1).Info(...)but displayed asDEBUGin the output.-zap-log-levelcontrols the minimum log level (info, error, etc.), but does NOT control the verbosity threshold for V(n) logs.Note:
ConsoleEncodertoJsonEncoder(see examples below)1.Pre this PR:
Post this PR (without log level being overriden as we do when running locally - note the missing "debug" logs):
Footnotes
If anyone is opposed to JSON logs locally then we can reconfigure these locally but this will require updates to the Helm chart that I'm trying to avoid pending the switch to using env vars instead of args in feat(controller): support HA deployment #1133. Specifically, I don't want to add
controller.argsto the values now when that could subsequently be removed (breaking change) in the linked PR. ↩