fix: honor klog -stderrthreshold even when -logtostderr is true#1101
fix: honor klog -stderrthreshold even when -logtostderr is true#1101pierluigilenoci wants to merge 3 commits into
Conversation
|
Hi @pierluigilenoci. Thanks for your PR. I am @kingmakerbot.
Make sure this PR appears in the CrownLabs changelog, adding one of the following labels:
|
|
Hi @pierluigilenoci, thanks for your contribution. |
|
Hi @QcFe, thanks for the review! You're absolutely right — I'm sorry about the broken state. I've pushed a fix (62f8e4b) that addresses all the issues you raised: Restored accidentally deleted directives:
Added explanatory nolint comments: Regarding helm chart changes: The Thanks again for catching these! |
39bcebf to
bda5974
Compare
klog v2 defaults -logtostderr to true, which silently ignores -stderrthreshold — all log levels go to stderr unconditionally. This has been an open issue since 2020 (kubernetes/klog#212). klog v2.140.0 introduced a fix behind an opt-in flag (legacy_stderr_threshold_behavior). This commit bumps klog to v2.140.0 and enables the fix in all operator entry points and the custom-error-pages server so that -stderrthreshold is honored, while preserving the current default behavior (stderrthreshold=INFO means all logs still go to stderr unless the user overrides it on the command line). Modified files: - operators/cmd/instmetrics/main.go - operators/cmd/instance-automation/main.go - operators/cmd/bastion-operator/main.go - operators/cmd/instance-operator/main.go - operators/cmd/operator/main.go - operators/pkg/examagent/options.go - infrastructure/ingress-controller/custom-error-pages/server/main.go Ref: kubernetes/klog#212 Ref: kubernetes/klog#432 Signed-off-by: Pierluigi Lenoci <pierluigilenoci@gmail.com>
Restore crucial lines that were accidentally removed when adding the klog stderrthreshold fix: - bastion-operator: restore ctrl.NewManager call - instance-automation: restore ctrl.SetLogger, log, and whiteListMap - instance-operator: restore ctrl.SetLogger - instmetrics: restore log variable initialization - operator: restore SetLogger comment - examagent: restore Parse doc comment - custom-error-pages: restore "Load response templates" comment Also add explanatory comments to all //nolint:errcheck directives as required by project linting conventions. Signed-off-by: Pierluigi Lenoci <pierluigilenoci@gmail.com>
The nolint:errcheck directive suppresses the errcheck linter but not gosec, which independently reports G104 (Errors unhandled) for the same flag.Set() calls. Add gosec to the nolint directive to suppress both linters consistently across all six files. Signed-off-by: Pierluigi Lenoci <pierluigilenoci@gmail.com>
bda5974 to
f1f68d5
Compare
What changed
klog v2 defaults
-logtostderrtotrue, which silently ignores-stderrthreshold— all log levels go to stderr unconditionally. This has been an open issue since 2020.klog v2.140.0 introduced a fix behind an opt-in flag (
legacy_stderr_threshold_behavior). This PR bumps klog to v2.140.0 across both go.mod files and enables the fix in all 7 entry points:operators/cmd/instmetrics/main.gooperators/cmd/instance-automation/main.gooperators/cmd/bastion-operator/main.gooperators/cmd/instance-operator/main.gooperators/cmd/operator/main.gooperators/pkg/examagent/options.goinfrastructure/ingress-controller/custom-error-pages/server/main.goThe fix preserves the current default behavior (
stderrthreshold=INFOmeans all logs still go to stderr unless the user explicitly overrides it on the command line).References